I connected a Drupal site to a non Drupal site using XMLRPC. The non Drupal site will be converted to Drupal in the future. I found a really easy way to connect that allows for the future conversion. here is the one minute version. I can post more details if someone else wants to perform the same trick.
Drupal XMLRPC clients use the Drupal xmlrpc.inc code. Drupal XMLRPC servers use the Drupal xmlrpcs.inc code and that includes xmlrpc.inc. You can use xmlrpcs.inc + xmlrpc.inc on non Drupal servers with the addition of a tiny extra bit of code. I put the extra code in xmlrpc_library.php, xmlrpc_library.php includes xmlrpcs.inc + xmlrpc.inc, and the source pages include just xmlrpc_library.php.
The Drupal client thinks it is talking with a Drupal server. If there is a problem at the server end, you can easily reproduce the event in a Drupal test site to check if the problem is the Drupal XMLRPC code or the server code. There are alternative XMLRPC libraries for servers but some are not actively maintained and some have differences that could create incompatibilities. It is silly to use different code when when you are converting all your sites to the One True CMS™. :-)
I am using Drupal client to non Drupal server. The reverse should also work. You could also use non to non if one or both sites are scheduled for upgrades to Drupal.
Comments
I want more details on this
Hi peterx,
I want to perform same type of operation, but reverse of this- non drupal to drupal. Can you please guide me and provide more details on this?
Thanks
Rushali
includes/xmlrpc.php
Copy includes/xmlrpc.php from a Drupal 6 site to your non Drupal site. I have no Drupal 5 sites so cannot tell you what happens in Drupal 5. I do not know if a Drupal 6 client can read from a Drupal 5 site or any other combination because all my sites are Drupal 6.
Copy function xmlrpc() from /includes/common.php into your code.
/includes/common.php contains xmlrpc(), the function you use to start your request. Read http://api.drupal.org/api/function/xmlrpc. Call xmlrpc() with something like:
Result = xmlrpc('http://example.com/get_local_amount.php', 'convert.au', 29.78);xmlrpc() includes xmlrpc.php then calls _xmlrpc() to perform the work. You can copy the /includes directory used by Drupal. If your current include directory is /code then place xmlrpc() in /code and xmlrpc.php in /code/includes/.
RPC needs the URL of the script that accepts RPC. In Drupal it is example.com/xmlrpc.php. You can use anything you like.
You then need a request string. is fine to begin with. Then you need more complex requests. You then use action.item. might convert Australian dollars to US dollars and might convert British pounds to US dollars.
The rest of the parameters are the values you supply, in this case the number of pounds or dollars.
The result is an XML structure you can decode using one of the functions in xmlrpc.php. Check the result for errors before using the result.
petermoulding.com/web_architect
petermoulding.com/web_architect
Calling Drupal's XML-RPC methods using PHP's native functions
I wrote some functions that use PHP's xmlrpc extension (http://us3.php.net/xmlrpc). You can check them out here:
http://groups.drupal.org/node/21302