xmlrpc.module 2.08 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
<?php

/**
 * @file
 * Enables XML-RPC functionality.
 */

/**
 * Implements hook_help().
 */
function xmlrpc_help($path, $args) {
  switch ($path) {
    case 'admin/help#xmlrpc':
      $output = '';
      $output .= '<p>' . t('The XML-RPC module gives external systems the opportunity to communicate with the site through the XML-RPC protocol. Pointing an XML-RPC client at <a href="@xmlrpc">xmlrpc.php</a> allows this communication to take place. For more information, see the online handbook entry for <a href="@xmlrpcapi">XML-RPC API</a>.', array(
        '@xmlrpc' => url('xmlrpc.php', array('absolute' => TRUE)),
        '@xmlrpcapi' => 'http://drupal.org/node/44895',
      )) . '</p>';
      return $output;
  }
}

/**
 * Implements hook_menu().
 */
function xmlrpc_menu() {
  $items['xmlrpc.php'] = array(
    'title' => 'XML-RPC',
    'page callback' => 'xmlrpc_server_page',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
    'file' => 'xmlrpc.server.inc',
  );
  return $items;
}

/**
 * Performs one or more XML-RPC request(s).
 *
 * Usage example:
 * @code
 * $result = xmlrpc('http://example.com/xmlrpc.php', array(
 *   'service.methodName' => array($parameter, $second, $third),
 * ));
 * @endcode
 *
47
 * @param string $url
48
 *   An absolute URL of the XML-RPC endpoint.
49
 * @param array $args
50 51 52
 *   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.
53 54
 * @param array $headers
 *   (optional) An array of headers to pass along.
55 56 57 58 59 60 61 62 63 64
 *
 * @return
 *   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().
 */
65
function xmlrpc($url, array $args, array $headers = array()) {
66
  module_load_include('inc', 'xmlrpc');
67
  return _xmlrpc($url, $args, $headers);
68
}