Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9182311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:31:49+00:00 2026-06-17T18:31:49+00:00

I am building a small system which will pull products from an API and

  • 0

I am building a small system which will pull products from an API and put each product into drupal db as nodes when the script is run. I am new to Drupal so I hope you will forgive any stupidness. So here is a very simple break down of what I have done so far.

  1. Used php simplexml to extract products using API.

2.Stored product name description,url etc in php variables.

  1. At this point I need to add them to Drupal as nodes. I got this code from web which is exactly what I require (I think )

    $node = new stdClass(); 
    $node->type = "page"; 
    $node->title = "Title";
    $node->language = LANGUAGE_NONE; 
    $node->path = array('alias' => 'your node path'); // Setting a node path
    node_object_prepare($node); // Set some default values.
    $node->uid = 1; 
    

So simply putting my PHP variable in each of the above variable will do the trick. But I am stuck at where to put all this and my code? I mean do I create new php file in the drupal root or what? What files to include into it .How to do this.

Any help will be appreciated.

Regards,
Ahmar.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:31:50+00:00Added an answer on June 17, 2026 at 6:31 pm

    The way Ghommey said does work, however if you don’t want to have to do it by creating a module and then going to a page you can use drupal_bootstrap() to allow you to include drupal into a .php file. Link to Documentation Here is a code sample:

    define('DRUPAL_ROOT', '/path/to/drupal');
    require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    
    //add create node object here
    node_save($node);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a small system which throws data from a mongodb collection, it
I'm building this small java applet in which I need a JPanel which will
Background: I'm building a small application that will be run daily, pulling data from
I'm building a small system, which has nice htaccess rewritten urls. Now I'm wondering
I am building a small cms system in MVC.NET, and I have some editable
I'm building a small messaging system like you have in facebook. Only thing is
We are developing an application which accesses an API exposed over some embedded system.
Here is my situation. I am building a small Windows Form that will launch
I'm building a small Java library which has to match units in strings. For
As you might guess I'm building a small chat system, and I would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.