You are here

public static function clients_connection_flickr::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

Parameters

$serviceConfig: stdClass: A service configuration as returned by Clients::load()

$serviceMethod: string: Name of service method to access

Return value

array: a valid token

1 call to clients_connection_flickr::getToken()
clients_connection_flickr::getUser in backends/clients_flickr/clients_flickr.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_flickr/clients_flickr.inc, line 36
Defines Flickr services and calls

Class

clients_connection_flickr

Code

public static function getToken($connection, $serviceMethod) {

  // @todo - http://www.flickr.com/services/api/auth.howto.web.html
  $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,
  );
}