function clients_connection_drupal_services_6_2::callMethod in Web Service Clients 7
Call a remote method.
Parameters
$method: The name of the remote method to call.
All other parameters are passed to the remote method.:
Return value
Whatever is returned from the remote site.
Overrides clients_connection_drupal_services::callMethod
3 calls to clients_connection_drupal_services_6_2::callMethod()
- clients_connection_drupal_services_6_2::testConnectionConnect in backends/
clients_drupal/ clients_drupal.inc - Connection test button handler: basic connection.
- clients_connection_drupal_services_6_2::testConnectionLogin in backends/
clients_drupal/ clients_drupal.inc - Connection test button handler: user login.
- clients_connection_drupal_services_6_2::testConnectionNodeLoad in backends/
clients_drupal/ clients_drupal.inc - Connection test button handler: loading a node.
1 method overrides clients_connection_drupal_services_6_2::callMethod()
- clients_connection_drupal_services_5::callMethod in backends/
clients_drupal/ clients_drupal.inc - Call a remote method.
File
- backends/
clients_drupal/ clients_drupal.inc, line 380 - Defines methods and calls to Drupal services
Class
- clients_connection_drupal_services_6_2
- Drupal client for services on a Drupal 6 site for Services 6.x-2.x.
Code
function callMethod($method) {
// If HTTP requests are enabled, report the error and do nothing.
// (Cribbed from Content distribution module.)
if (variable_get('drupal_http_request_fails', FALSE) == TRUE) {
drupal_set_message(t('Drupal is unable to make HTTP requests. Please reset the HTTP request status.'), 'error', FALSE);
watchdog('integration', 'Drupal is unable to make HTTP requests. Please reset the HTTP request status.', array(), WATCHDOG_CRITICAL);
return;
}
$config = $this->configuration;
$endpoint = $this->endpoint;
$api_key = $this->configuration['servicekey'];
// Connect to the remote system service to get an initial session id to log in with.
$connect = xmlrpc($this->endpoint, 'system.connect');
$session_id = $connect['sessid'];
// We may want to call only system.connect for testing purposes.
if ($method == 'system.connect') {
return $connect;
}
// Log in
// Get the API key-related arguments.
$key_args = $this
->xmlrpc_key_args('user.login');
//dsm($key_args);
// Build the array of connection arguments we need to log in.
$username = $this->configuration['username'];
$password = $this->configuration['password'];
$login_args = array_merge(array(
$this->endpoint,
'user.login',
), $key_args, array(
$session_id,
), array(
$username,
$password,
));
// Call the xmlrpc method with our array of arguments. This accounts for
// whether we use a key or not, and the extra parameters to pass to the method.
$login = call_user_func_array('xmlrpc', $login_args);
$login_session_id = $login['sessid'];
// If the requested method is user.login, we're done.
if ($method == 'user.login') {
return $login;
}
// Get all the arguments this function has been passed.
$function_args = func_get_args();
// Slice out the ones that are arguments to the method call: everything past
// the 1st argument.
$method_args = array_slice($function_args, 1);
// Get the API key-related arguments.
$key_args = $this
->xmlrpc_key_args($method);
// Build the array of connection arguments for the method we want to call.
$xmlrpc_args = array_merge(array(
$this->endpoint,
$method,
), $key_args, array(
$login_session_id,
), $method_args);
// Call the xmlrpc method with our array of arguments.
$result = call_user_func_array('xmlrpc', $xmlrpc_args);
if ($result === FALSE) {
//dsm('error');
return xmlrpc_error();
}
return $result;
}