In our system, the content is generated by a standalone PHP script that runs from command line. Is there a way to add this content programmatically to a remote Drupal 7 CMS from this standalone PHP script?
I am not able to find such information on drupal.org. I have found the following code:
$node = new stdClass(); // Set content type $node->type = 'article'; // Prepare defaults node_object_prepare($node); // Define language (currently language neutral) $node->language = LANGUAGE_NONE; // Basic content $node->title = 'Test'; $node->body[$node->language]['value'] = 'Body text'; // Example if using custom fields $node->field_CUSTOM_FIELD[$node->language]['value'] = 'Value'; // Example if using fields that are taxonomy type $node->field_CUSTOM_FIELD_TAXONOMY[$node->language]['tid'] = 1; // Save node node_save($node);
But this code has to run from Drupal 7 server process only. This code cannot be used in a standalone PHP script that runs remotely. Another option is Entity API but that code too has to run on Drupal Server only. Do I need to create my own module and code my standalone PHP script to connect to API exposed by this module?