You are here

function hook_xmlrpc in Drupal 7

Register XML-RPC callbacks.

This hook lets a module register callback functions to be called when particular XML-RPC methods are invoked by a client.

Return value

An array which maps XML-RPC methods to Drupal functions. Each array element is either a pair of method => function or an array with four entries:

  • The XML-RPC method name (for example, module.function).
  • The Drupal callback function (for example, module_function).
  • The method signature is an array of XML-RPC types. The first element of this array is the type of return value and then you should write a list of the types of the parameters. XML-RPC types are the following (See the types at http://www.xmlrpc.com/spec):

    • "boolean": 0 (false) or 1 (true).
    • "double": a floating point number (for example, -12.214).
    • "int": a integer number (for example, -12).
    • "array": an array without keys (for example, array(1, 2, 3)).
    • "struct": an associative array or an object (for example, array('one' => 1, 'two' => 2)).
    • "date": when you return a date, then you may either return a timestamp (time(), mktime() etc.) or an ISO8601 timestamp. When date is specified as an input parameter, then you get an object, which is described in the function xmlrpc_date
    • "base64": a string containing binary data, automatically encoded/decoded automatically.
    • "string": anything else, typically a string.
  • A descriptive help string, enclosed in a t() function for translation purposes.

Both forms are shown in the example.

Related topics

1 function implements hook_xmlrpc()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

xmlrpc_test_xmlrpc in modules/simpletest/tests/xmlrpc_test.module
Implements hook_xmlrpc().
1 invocation of hook_xmlrpc()
xmlrpc.php in ./xmlrpc.php
PHP page for handling incoming XML-RPC requests from clients.

File

modules/system/system.api.php, line 2440
Hooks provided by Drupal core and the System module.

Code

function hook_xmlrpc() {
  return array(
    'drupal.login' => 'drupal_login',
    array(
      'drupal.site.ping',
      'drupal_directory_ping',
      array(
        'boolean',
        'string',
        'string',
        'string',
        'string',
        'string',
      ),
      t('Handling ping request'),
    ),
  );
}