public static function clients_connection_drupal_services::getToken in Web Service Clients 7
Prepares a hashed token for the service, based on current time, the required service and config values; serviceKey and serviceDomain t
Parameters
$connection: stdClass: A service connection as returned by Clients::load()
$serviceMethod: string: Name of service method to access
Return value
array a valid token
2 calls to clients_connection_drupal_services::getToken()
- clients_connection_drupal_services::fetch in backends/
clients_drupal/ clients_drupal.inc - Gets raw data from service call
- clients_connection_drupal_services::getUser in backends/
clients_drupal/ clients_drupal.inc - Connects to Drupal Services and logs in the user provided in the config. Returns a session for the user. @todo needs error catching in case service is down
File
- backends/
clients_drupal/ clients_drupal.inc, line 232 - Defines methods and calls to Drupal services
Class
- clients_connection_drupal_services
- General Drupal client class.
Code
public static function getToken($connection, $serviceMethod) {
$timestamp = (string) time();
$nonce = uniqid();
$hashParameters = array(
$timestamp,
$connection->configuration['domain'],
$nonce,
$serviceMethod,
);
$hash = hash_hmac("sha256", implode(';', $hashParameters), $connection->configuration['servicekey']);
return array(
'hash' => $hash,
'domain' => $connection->configuration['domain'],
'timestamp' => $timestamp,
'nonce' => $nonce,
);
}