| 5 common.inc | xmlrpc($url) |
| 6 common.inc | xmlrpc($url) |
| 7 common.inc | xmlrpc($url, $args, $options = array()) |
| 8 common.inc | xmlrpc($url, $args, $options = array()) |
Performs one or more XML-RPC request(s).
Usage example:
$result = xmlrpc('http://example.com/xmlrpc.php', array(
'service.methodName' => array($parameter, $second, $third),
));
Parameters
$url: An absolute URL of the XML-RPC endpoint.
$args: An associative array whose keys are the methods to call and whose values are the arguments to pass to the respective method. If multiple methods are specified, a system.multicall is performed.
$options: (optional) An array of options to pass along to drupal_http_request().
Return value
For one request: Either the return value of the method on success, or FALSE. If FALSE is returned, see xmlrpc_errno() and xmlrpc_error_msg(). For multiple requests: An array of results. Each result will either be the result returned by the method called, or an xmlrpc_error object if the call failed. See xmlrpc_error().
5 calls to xmlrpc()
2 string references to 'xmlrpc'
File
- includes/
common.inc, line 7862 - Common functions that many Drupal modules will need to reference.
Code
function xmlrpc($url, $args, $options = array()) {
require_once DRUPAL_ROOT . '/includes/xmlrpc.inc';
return _xmlrpc($url, $args, $options);
}
Login or register to post comments
Comments
Example
This is how you would use drupal's xmlrpc to call another drupal site
$result = xmlrpc('http://drupal-install-domain.com/xmlrpc.php', array(array('system.method', $param1, $param2, $param3),
));
This is incorrect. Second
This is incorrect. Second parameter has to be assoc array. Correct code:
$result = xmlrpc('http://drupal-install-domain.com/xmlrpc.php', array('system.method' => array( $param1, $param2, $param3),
));
Example: system.listMethods
This works (note the empty array() of parameters):
$methods = xmlrpc($url, array('system.listMethods' => array()));
Calling same method with different parameters
Even though xmlrpc supports specifying more than one method in args array, one obvious limitation is that you can not specify the same method (key) more than once. Solution is to use built-in 'system.multicall' method:
$rc = xmlrpc( $xmlrpc_url, array('system.multicall' => array(
array( 'methodName ' => '<method name1>', 'params' => array( <param 1.1>, ...)),
array( 'methodName ' => '<method name2>', 'params' => array( <param 2.1>, ...)),
...
array( 'methodName ' => '<method nameN>', 'params' => array( <param N.1>, ...)),
)
));