You are here

function xmlrpc_server_multicall in xmlrpc 8

Dispatches multiple XML-RPC requests.

Parameters

array $method_calls: An array of XML-RPC requests to make. Each request is an array with the following elements:

  • methodName: Name of the method to invoke.
  • params: Parameters to pass to the method.

Return value

array An array of the results of each request.

See also

xmlrpc_server_call()

1 string reference to 'xmlrpc_server_multicall'
xmlrpc_server in ./xmlrpc.server.inc
Invokes XML-RPC methods on this server.

File

./xmlrpc.server.inc, line 280
Page callback file for the xmlrpc module.

Code

function xmlrpc_server_multicall(array $method_calls) {

  // See http://www.xmlrpc.com/discuss/msgReader$1208
  $return = [];
  $xmlrpc_server = xmlrpc_server_get();
  foreach ($method_calls as $call) {
    $ok = TRUE;
    if (!isset($call['methodName']) || !isset($call['params'])) {
      $result = xmlrpc_error(3, t('Invalid syntax for system.multicall.'));
      $ok = FALSE;
    }
    $method = $call['methodName'];
    $params = $call['params'];
    if ($method == 'system.multicall') {
      $result = xmlrpc_error(-32600, t('Recursive calls to system.multicall are forbidden.'));
    }
    elseif ($ok) {
      $result = xmlrpc_server_call($xmlrpc_server, $method, $params);
    }
    if (is_object($result) && !empty($result->is_error)) {
      $return[] = [
        'faultCode' => $result->code,
        'faultString' => $result->message,
      ];
    }
    else {
      $return[] = [
        $result,
      ];
    }
  }
  return $return;
}