public function DrupalOAuthDataStore::lookup_nonce in OAuth 1.0 6.3
Same name and namespace in other branches
- 6 oauth.module \DrupalOAuthDataStore::lookup_nonce()
- 7.4 includes/DrupalOAuthDataStore.inc \DrupalOAuthDataStore::lookup_nonce()
- 7.3 includes/DrupalOAuthDataStore.inc \DrupalOAuthDataStore::lookup_nonce()
Check if the nonce value exists. If not, generate one.
Parameters
OAuthConsumer $consumer: The service consumer information with both key and secret values.
OAuthToken $token: The current token.
string $nonce: A new nonce value, in case a one doesn't current exit.
int $timestamp: The current time.
Return value
string The existing nonce value or NULL in case it doesn't exist.
Overrides OAuthDataStore::lookup_nonce
File
- includes/
DrupalOAuthDataStore.inc, line 72
Class
- DrupalOAuthDataStore
- Database abstraction class
Code
public function lookup_nonce($consumer, $token, $nonce, $timestamp) {
if (strlen($nonce) > 255) {
throw new OAuthException('Nonces may not be longer than 255 characters');
}
$stored_nonce = db_result(db_query("SELECT nonce FROM {oauth_common_nonce}\n WHERE nonce = '%s' AND timestamp <= %d and token_key = '%s'", array(
':nonce' => $nonce,
':timestamp' => $timestamp,
':token_key' => $token ? $token->key : '',
)));
if (!$stored_nonce) {
$values = array(
'nonce' => $nonce,
'timestamp' => $timestamp,
'token_key' => $token ? $token->key : '',
);
drupal_write_record('oauth_common_nonce', $values);
return NULL;
}
return $stored_nonce;
}