call drupal function from external php file

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by mirian@drupal.org on June 25, 2008 at 9:18am

Hi all,

I'v just heard about this module and understood it might help me...
I want to get values from external php script which will call drupal function that will take the data and call "node_save" with new node that contain the relevant data (which was arrived from the external php)

I don't understand how services can solve it.

Thanks,
Miriam.

Comments

CURL

Posted by andremolnar on July 28, 2008 at 12:25am

I'm not sure what you are trying to do, but you can use cURL to call your web services from another php file/ application.

This is in fact the way that I test all my web services. I run a testing script that uses cURL to send good/bad data to the services and tests the return values from the services.

andre

Can you show a code example

Posted by amitaibu on July 28, 2008 at 8:35am

Can you show a code example of how you use the cURL? [edit: here's a short Drupal code example on cURL].

@miriam, you can also use:

<?php
$node
= node_load(1);
xmlrpc('http://example.com/services/xmlrpc', 'node.save', $node);
?>

not exteral to drupal

Posted by tomhung on August 13, 2008 at 3:51pm

this code does not work external to drupal.

can someone show a simple example xml-rpc client using php to connect to drupal services with node.load and/or node.save

I can't seem to get it to connect. i keep getting the following

<?xml version="1.0"?>
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><int>-32602</int></value>
</member>
<member>
<name>faultString</name>
<value><string>Server error. Wrong number of method parameters.</string></value>
</member>
</struct>
</value>
</fault>
</methodResponse>

The example should work from

Posted by amitaibu on August 13, 2008 at 7:38pm

The example should work from one drupal site to another, you might need to set access permissions to allow it to work. Also remove the API key and Sess Id for the example to work.

Here an even better tutorial

Posted by amitaibu on July 28, 2008 at 9:04am

Here an even better tutorial - http://drupal.org/node/86727

Services

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /