function xmlrpc_example_xmlrpc in Examples for Developers 7
Same name and namespace in other branches
- 6 xmlrpc_example/xmlrpc_example.module \xmlrpc_example_xmlrpc()
Implements hook_xmlrpc().
Provides Drupal with an array to map XML-RPC callbacks to existing functions. These functions may be defined in other modules. The example implementation defines specific functions for the example services.
Note: Drupal's built-in XML-RPC server already includes several methods by default:
Service dicovery methods:
- system.listMethods: return a list of the methods the server has, by name.
- system.methodSignature: return a description of the argument format a
- system.methodHelp: returns a text description of a particular method. particular method expects.
Other:
- system.multicall: perform several method calls in a single xmlrpc request.
- system.getCapabilities: determine if a given capability is supported.
The methods defined by hook_xmlrpc() will be added to those provided by default by Drupal's XML-RPC server.
See also
Related topics
File
- xmlrpc_example/
xmlrpc_example.module, line 172 - Module file for xmlrpc_example module.
Code
function xmlrpc_example_xmlrpc() {
$methods[] = array(
// First argument is the method name.
'xmlrpc_example.add',
// Callback to execute when this method is requested.
'_xmlrpc_example_server_add',
// An array defines the types of output and input values for this method.
array(
// The first value is the return type, an integer in this case.
'int',
// First operand is an integer.
'int',
// Second operand is an integer.
'int',
),
// Include a little description that is shown when XML-RPC server is
// requested for the implemented methods list.
// Method description.
t('Returns the sum of the two arguments.'),
);
// The subtract method is similar to the addition, only the method name,
// callback and description are different.
$methods[] = array(
'xmlrpc_example.subtract',
'_xmlrpc_example_server_subtract',
array(
'int',
'int',
'int',
),
t('Return difference of the two arguments.'),
);
return $methods;
}