You are here

function _xmlrpc_example_server_add in Examples for Developers 6

Same name and namespace in other branches
  1. 7 xmlrpc_example/xmlrpc_example.module \_xmlrpc_example_server_add()

Sum the two arguments.

This is the callback for the xmlrpc_example.add xmlrpc method.

Parameters

$num1:

$num2:

Return value

The sum of the arguments, or error if it is not in server defined bounds.

See also

xmlrpc_error()

Related topics

1 string reference to '_xmlrpc_example_server_add'
xmlrpc_example_xmlrpc in xmlrpc_example/xmlrpc_example.module
Implements hook_xmlrpc().

File

xmlrpc_example/xmlrpc_example.module, line 168
This is an example of how to implement an XML-RPC server by registering callbacks to specific methods and how to make xmlrpc calls using the builtin xmlrpc() factory provided by Drupal.

Code

function _xmlrpc_example_server_add($num1, $num2) {
  $sum = $num1 + $num2;

  // If result is not within maximum and minimum limits, return corresponding error
  if ($sum > variable_get('xmlrpc_example_server_max', 10)) {
    return xmlrpc_error(10001, t("Result is over the higher limit defined by the server."));
  }
  if ($sum < variable_get('xmlrpc_example_server_min', 0)) {
    return xmlrpc_error(10002, t("Result is under the lower limit defined by the server."));
  }

  // Otherwise return the result.
  return $sum;
}