Hi Drupal Gurus

I'm busy with an external module. I'm having some trouble with XML-RPC. I just need a solid XML-RPC example in drupal to get me going. So please your assistance will be greatly appreciated.

Thanks

Comments

matt_harrold’s picture

http://api.drupal.org/api/file/developer/examples/xmlrpc_example.module/5

I haven't tried to do this yet, so I don't know how helpful the documentation is, but the example modules for other tasks worked fine.

Good luck.

dianacastillo’s picture

Use the services module: see http://drupal.org/node/1851202

Diana Castillo

mooffie’s picture

A quickie:

There are two parts to XML-RPC:
1. exposing functions (let's call them 'services');
2. calling exposed services.

Exposing:

See the Organic Groups module for an example of how to expose services. There's also the built-in blogapi.module. There's also the example Matthew linked to.

Calling:

You use the xmlrpc() Drupal function to call an exposed function. This function accepts as arguments the URL of the remote site, the name of the exposed function there, and then some arguments. Here's how to call Drupal's 'listMethods' service, which simply list all other available exposed functions:

include_once './includes/xmlrpc.inc';
$ret = xmlrpc('http://localhost/~mooffie/drupal5n/xmlrpc.php', 'system.listMethods');
if ($ret === FALSE) {
  print_r( xmlrpc_error_msg() );
} else {
  print_r( $ret );
}

(Of course, the URL above is on my computer. Change it to match yours.)

Have you googled for "drupal xmlrpc"?

iantresman’s picture

It's taken me a while to work out what XML-RPC and the supplied /xmlrpc.php file does. In a nutshell, it's a way to use XML to make remote procedure calls (RPC), or to put it another way, to send commands to a Drupal installation, and respond. This could be to provide information, or, if it has been enabled, to carry out commands.

After some trial and error, and some Google searching, you can not use an HTML form to post data to a Drupal installation, because the data must be in XML format. Forms can not do that. So you must use PHP to send your call (command), and have it handle the response. here's a very basic PHP snippet that works for me, that responds by indicate what XML-RPC commands (methods) are built-in to Drupal.

<?php 
$methods = xmlrpc('http://drupal.org/xmlrpc.php', 'system.listMethods');
echo "<pre>";
print_r($methods);
echo "</pre>";
?>

You can paste this into a new story/article/node, as long as you have set the Input format to handle PHP code (enabled in Modules|Core). You should see the following results:

Array
(
    [0] => system.multicall
    [1] => system.methodSignature
    [2] => system.getCapabilities
    [3] => system.listMethods
    [4] => system.methodHelp
    [5] => drupal.login
)

There is not much more you can do with Drupal's default XML-RPC handling, but if you install the excellent Drupal Remote Dashboard Server, then you'll get new functionality (you'll need to write your own XML-RPC server functions to extend the functionality):

Array
(
    [0] => system.multicall
    [1] => system.methodSignature
    [2] => system.getCapabilities
    [3] => system.listMethods
    [4] => system.methodHelp
    [5] => drd.api
    [6] => drd.connect
    [7] => drd.session.valid
    [8] => drd.info
    [9] => drd.cache.flush
    [10] => drd.run.cron
    [11] => drd.switch.maintenance
    [12] => drd.list.updates
    [13] => drd.run.update
    [14] => drd.server.domains
    [15] => drd.server.svn.status
    [16] => drd.server.svn.update
    [17] => drd.server.php.error.log
)

For more details

Karlheinz’s picture

So you must use PHP to send your call (command), and have it handle the response.

Just a clarification: You need to use a language that can send data using XML.

PHP is the most common one - but you could code a client to do RPC calls using e.g. JavaScript and AJAX, or even Cocoa for you iPhone users.

-Karlheinz

iantresman’s picture

I guess you could use another language.

Karlheinz’s picture

Sorry for the late reply...

The reason I bring this up, is because XML-RPC is extremely powerful. It allows you to not just query for content, but also to create content using any program that can send XML data.

For example: You're at a concert or something, and you get a great shot of the singer on your iPhone. If some iPhone developer out there made an app, you could send that picture to your Drupal site with the touch of a button, and it would be on the web before the concert was even over.

-Karlheinz

snufkin’s picture

You can also take a look at xmlrpctester to help with exploring available remote methods, create and test custom ones on the fly.

rolodmonkey’s picture

This article I wrote has a pretty good description of how XML-RPC works:

http://forum.openlaszlo.org/showthread.php?s=b213579acc0c479a80f5e210a67...

--

Read more at iRolo.net