function _twitter_signin_add_account in Twitter 6.5
Same name and namespace in other branches
- 7.6 twitter_signin/twitter_signin.module \_twitter_signin_add_account()
- 7.3 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.
1 call to _twitter_signin_add_account()
- twitter_signin_user in twitter_signin/
twitter_signin.module - Implements hook_user().
File
- twitter_signin/
twitter_signin.module, line 283 - Hook implementations for twitter_signin submodule.
Code
function _twitter_signin_add_account($edit, $account) {
if (isset($_SESSION['twitter']['values'])) {
module_load_include('inc', 'twitter');
$key = variable_get('twitter_consumer_key', '');
$secret = variable_get('twitter_consumer_secret', '');
$response = $_SESSION['twitter']['values'];
$twitter = new Twitter($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->uid = $account->uid;
twitter_account_save($twitter_account, TRUE);
unset($_SESSION['twitter']);
drupal_set_message(t('You have related a Twitter account with your user. Next time you can sign in with Twitter.'));
}
}