You are here

function _xmlrpc in Drupal 4

Same name and namespace in other branches
  1. 5 includes/xmlrpc.inc \_xmlrpc()
  2. 6 includes/xmlrpc.inc \_xmlrpc()
  3. 7 includes/xmlrpc.inc \_xmlrpc()

Execute an XML remote procedural call. This is private function; call xmlrpc() in common.inc instead of this functino.

Return value

A $xmlrpc_message object if the call succeeded; FALSE if the call failed

1 string reference to '_xmlrpc'
xmlrpc in includes/common.inc
Performs one or more XML-RPC request(s).

File

includes/xmlrpc.inc, line 425

Code

function _xmlrpc() {
  $args = func_get_args();
  $url = array_shift($args);
  if (is_array($args[0])) {
    $method = 'system.multicall';
    $multicall_args = array();
    foreach ($args[0] as $call) {
      $multicall_args[] = array(
        'methodName' => array_shift($call),
        'params' => $call,
      );
    }
    $args = array(
      $multicall_args,
    );
  }
  else {
    $method = array_shift($args);
  }
  $xmlrpc_request = xmlrpc_request($method, $args);
  $result = drupal_http_request($url, array(
    "Content-Type" => "text/xml",
  ), 'POST', $xmlrpc_request->xml);
  if ($result->code != 200) {
    xmlrpc_error(-$result->code, $result->error);
    return FALSE;
  }
  $message = xmlrpc_message($result->data);

  // Now parse what we've got back
  if (!xmlrpc_message_parse($message)) {

    // XML error
    xmlrpc_error(-32700, t('Parse error. Not well formed'));
    return FALSE;
  }

  // Is the message a fault?
  if ($message->messagetype == 'fault') {
    xmlrpc_error($message->fault_code, $message->fault_string);
    return FALSE;
  }

  // Message must be OK
  return $message->params[0];
}