hook_xmlrpc

  1. drupal
    1. 5 core.php
    2. 6 core.php
    3. 7
    4. 8
Versions
5 – 8 hook_xmlrpc()

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

Code

modules/system/system.api.php, line 2192

<?php
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'),
    ),
  );
}
?>