function xmlrpc_example_client_subtract_submit in Examples for Developers 6
Same name and namespace in other branches
- 7 xmlrpc_example/xmlrpc_example.module \xmlrpc_example_client_subtract_submit()
Submit for subtraction: Call the xmlrpc method and report the result.
_state
Parameters
$form:
See also
xmlrpc()
xmlrpc_example_client_add_submit()
Related topics
1 string reference to 'xmlrpc_example_client_subtract_submit'
- xmlrpc_example_client_form in xmlrpc_example/
xmlrpc_example.module - Present a form that makes use of xmlrpc services to add or subtract.
File
- xmlrpc_example/
xmlrpc_example.module, line 295 - 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_client_subtract_submit($form, &$form_state) {
$server = url($GLOBALS['base_url'] . "/xmlrpc.php");
$result = xmlrpc($server, 'xmlrpc_example.subtract', (int) $form_state['values']['num1'], (int) $form_state['values']['num2']);
if ($result === FALSE) {
drupal_set_message(t("Error return from xmlrpc(): Error: @errno, Message: @message", array(
'@errno' => xmlrpc_errno(),
'@message' => xmlrpc_error_msg(),
)));
}
else {
drupal_set_message(t("The XMLRPC server returned this response: @response", array(
'@response' => print_r($result, TRUE),
)));
}
}