You are here

function hook_xmlrpc in xmlrpc 8

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

array 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.

2 functions implement 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_example_xmlrpc in xmlrpc_example/xmlrpc_example.module
Implements hook_xmlrpc().
xmlrpc_test_xmlrpc in tests/modules/xmlrpc_test/xmlrpc_test.module
Implements hook_xmlrpc().

File

./xmlrpc.api.php, line 43
Hooks provided by the XML-RPC module.

Code

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