Hello.
I need to add cck nodes from php, but creating the php file from the begining, that is, this file will be called from a PC application and a it submits POST method (to pass some parameters).
I know how to add cck nodes using node_save etc, but I don't know how to add this function to the php file in order to use it.
What includes or stuff should I add to the php file in order to use node_save and other drupal api functions?
Thanks

Comments

rschwab’s picture

This probably belongs in the Module Development forum. At any rate, I think the Services API will help you achieve this.

briantes’s picture

Yes. I agree with you. I moved it to Module Development forum.

sagar ramgade’s picture

Hi,

You need to add this two lines at the start of your script, so that all drupal functions are available to your php script, remember this script will only if you place it in the root folder of drupal. I hope this helps.

<?php
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
?>

Regard
Sagar

Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form

briantes’s picture

Thanks for your answer. I was a little lost.
I'll try it. But only one question, Could I put the php file into another directory? I should only change the path for "required_once", no?

thanks

sagar ramgade’s picture

Hi,

I think you can use it inside any directory, Try this

<?php

chdir('/path/to/drupal/installation');
include_once(./includes/bootstrap.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

?>

Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form