function xmlrpc_example_client_subtract_submit

Submit handler to query xmlrpc_example.subtract.

Submit: query the XML-RPC endpoint for the method xmlrpc_example.subtract and report the result as a Drupal message.

Parameters

array $form: Form array.

array $form_state: Form_state array.

See also

xmlrpc()

xmlrpc_errno()

xmlrpc_error_msg()

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
Returns a form array to take input for two arguments.

File

xmlrpc_example/xmlrpc_example.module, line 505

Code

function xmlrpc_example_client_subtract_submit($form, &$form_state) {
    $server = url($GLOBALS['base_url'] . '/xmlrpc.php', array(
        'external' => TRUE,
    ));
    $options = array(
        'xmlrpc_example.subtract' => array(
            (int) $form_state['values']['num1'],
            (int) $form_state['values']['num2'],
        ),
    );
    // Make the xmlrpc request and process the results.
    $result = xmlrpc($server, $options);
    if ($result === FALSE) {
        drupal_set_message(t('Error return from xmlrpc(): Error: @errno, Message: @message', array(
            '@errno' => xmlrpc_errno(),
            '@message' => xmlrpc_error_msg(),
        )), 'error');
    }
    else {
        drupal_set_message(t('The XML-RPC server returned this response: @response', array(
            '@response' => print_r($result, TRUE),
        )));
    }
}