call drupal function from external php file

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.

Groups:
Login to post comments

CURL

andremolnar's picture
andremolnar - Mon, 2008-07-28 00:25

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

Amitaibu's picture
Amitaibu - Mon, 2008-07-28 08:35

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

tomhung's picture
tomhung - Wed, 2008-08-13 15:51

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

Amitaibu's picture
Amitaibu - Wed, 2008-08-13 19:38

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

Amitaibu's picture
Amitaibu - Mon, 2008-07-28 09:04

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