function clients_connection_call in Web Service Clients 7.2
Same name and namespace in other branches
- 6.2 clients.module \clients_connection_call()
- 7.3 clients.module \clients_connection_call()
Call a remote method on a client.
This the main API for Client connections and should be considered stable. Used thus: clients_connection_call('connection_machine_name', 'method_name', $params...); For example: clients_connection_call('my_connection', 'node.load', 1); will return node 1 loaded from the remote site.
Parameters
$name: The connection machine name.
$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.
Throws
Exception if the connection is not found or there is an error returned from the remote site.
File
- ./
clients.module, line 32 - Clients module provides a UI, storage, and an API for handling connections to remote webservices, including those provided by Services module on other Drupal sites.
Code
function clients_connection_call($name, $method) {
$connection = clients_connection_load($name);
if (!$connection) {
throw new Exception(t('Client connection %connection not found.', array(
'%connection' => $name,
)));
}
// 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 2nd argument.
$method_args = array_slice($function_args, 2);
$return = $connection
->callMethodArray($method, $method_args);
return $return;
}