public function Twitter::get_access_token in Twitter 7.6
Same name and namespace in other branches
- 6.5 twitter.lib.php \Twitter::get_access_token()
- 7.5 twitter.lib.php \Twitter::get_access_token()
Request an access token to the Twitter API.
Parameters
string$oauth_verifier: String an access token to append to the request or NULL.
Return value
String the access token or FALSE when there was an error.
See also
https://dev.twitter.com/docs/auth/implementing-sign-twitter
File
- ./
twitter.lib.php, line 86 - Integration layer to communicate with the Twitter REST API 1.1. https://dev.twitter.com/docs/api/1.1
Class
- Primary Twitter API implementation class
Code
public function get_access_token($oauth_verifier = NULL) {
$url = variable_get('twitter_api', TWITTER_API) . '/oauth/access_token';
// Adding parameter oauth_verifier to auth_request
$parameters = array();
if (!empty($oauth_verifier)) {
$parameters['oauth_verifier'] = $oauth_verifier;
}
try {
$response = $this
->auth_request($url, $parameters);
} catch (TwitterException $e) {
watchdog('twitter', '!message', array(
'!message' => $e
->__toString(),
), WATCHDOG_ERROR);
return FALSE;
}
parse_str($response, $token);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
}