You are here

function _xmlrpc in Drupal 6

Same name and namespace in other branches
  1. 4 includes/xmlrpc.inc \_xmlrpc()
  2. 5 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 function.

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 457
Drupal XML-RPC library. Based on the IXR - The Incutio XML-RPC Library - (c) Incutio Ltd 2002-2005 Version 1.7 (beta) - Simon Willison, 23rd May 2005 Site: http://scripts.incutio.com/xmlrpc/ Manual: http://scripts.incutio.com/xmlrpc/manual.php This…

Code

function _xmlrpc() {
  $args = func_get_args();
  $url = array_shift($args);
  xmlrpc_clear_error();
  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];
}