XML - RPC protocol was originally created by web developer Dave Winner from "UserLand software company" in cooperation with Microsoft in 1998. However, Microsoft Corp. soon found this protocol too simplistic, and started to expand its functionality (that later resulted in establishing the extended protocol SOAP). Despite the rejection by Microsoft, XML - RPC standard, with its extraordinary simplicity, has so far charmed many programmers. (Wikipedia)
In Drupal XML - RPC began it's existence in 4.6 version. Some minor changes in its operation occured after the release of Drupal 7.
First, let's set the tasks to ourselves and try to suggest the idea what we can utilize the XML - RPC protocol for. We've got 2 websites at our disposal:
- website "A"
- website "B"
The tasks are as follows:
1. learning all possible site "B's methods while staying onsite "A"
2. creating the functional for the content quantity output. Staying on site "A" we're supposed to controle the numbers of nodes on site "B" and vica verse.
3. creating a content functional of the site "B" while you stay on site "A" and vica verse
Task#1
Drupal has a list of system methods, which are available immediately after the installation's done. The list of standard methods is as follows:
1. system.multicall- a systematic method, that allows for activating additional methods.
2. system.methodSignature- returns an array, the description of the data return type and the required data type for the selected method.
3. system.getCapabilities- returns a description of the XML - RPC specification supported by this server.
4. system.listMethods- displays a list of available methods.
5. system.methodHelp- displays the description line for the specified method.
For solving the problem we need a method system, listMethods which displays all the methods of the site.
Reguest of any method is performed by using xmlrpc($url, $args, $options = array()).
Let's look at the function arguments, there are only three of them:
1. $url -the absolute addresses for file request, like «/example.com/xmlrpc.php».
2. $args -associative array whose keys reflected the methods which arguments are passing to the appropriate method. If several methods are not specified system.multicall are not satisfied too.
3. $options(not obvious argument) - the parameters of the query.
The only thing to do to get all site "B" methods is just to write the following line of code:
php $methods = xmlrpc('http://site-b.com/xmlrpc.php', array('system.listMethods' => array())
as a result of the query, we will print an array with all available methods for site "B". Also, you can get all available methods of the current site. You need only one argument of XML - RPC function to be changed that is to change website to which you address.