function _twitter_signin_add_account in Twitter 7.3
Same name and namespace in other branches
- 6.5 twitter_signin/twitter_signin.module \_twitter_signin_add_account()
- 7.6 twitter_signin/twitter_signin.module \_twitter_signin_add_account()
- 7.4 twitter_signin/twitter_signin.module \_twitter_signin_add_account()
- 7.5 twitter_signin/twitter_signin.module \_twitter_signin_add_account()
Relates a user account with a Twitter account.
Parameters
$account: The Drupal user account.
2 calls to _twitter_signin_add_account()
- twitter_signin_user_insert in twitter_signin/
twitter_signin.module - Implements hook_user_insert().
- twitter_signin_user_login in twitter_signin/
twitter_signin.module - Implements hook_user_login().
File
- twitter_signin/
twitter_signin.module, line 218
Code
function _twitter_signin_add_account($account) {
if (isset($_SESSION['twitter']['values'])) {
module_load_include('lib.php', 'twitter');
module_load_include('inc', 'twitter');
$key = variable_get('twitter_consumer_key', '');
$secret = variable_get('twitter_consumer_secret', '');
$response = $_SESSION['twitter']['values'];
$twitter = new TwitterOAuth($key, $secret, $response['oauth_token'], $response['oauth_token_secret']);
try {
$twitter_account = $twitter
->users_show($response['screen_name']);
} catch (TwitterException $e) {
drupal_set_message(t('Request failed: @message.', array(
'@message' => $e
->getMessage(),
)), 'error');
return;
}
$twitter_account
->set_auth($response);
twitter_account_save($twitter_account, TRUE, $account);
unset($_SESSION['twitter']);
drupal_set_message(t('You have related a Twitter account with your user. Next time you can sign in with Twitter.'));
}
}