function twitter_oauth_callback_submit in Twitter 6.5
Same name and namespace in other branches
- 6.3 twitter.pages.inc \twitter_oauth_callback_submit()
- 6.4 twitter.pages.inc \twitter_oauth_callback_submit()
Handle a Twitter OAuth return request and store the account creds in the DB.
File
- ./
twitter.pages.inc, line 492 - Page callbacks for Twitter module.
Code
function twitter_oauth_callback_submit(&$form, &$form_state) {
$key = variable_get('twitter_consumer_key', '');
$secret = variable_get('twitter_consumer_secret', '');
$response = $form_state['twitter_oauth']['response'];
$twitter = new Twitter($key, $secret, $response['oauth_token'], $response['oauth_token_secret']);
try {
$twitter_account = $twitter
->users_show($response['screen_name']);
// Save the new Twitter account and set the user's uid who added it.
$twitter_account
->set_auth($response);
global $user;
$twitter_account->uid = $user->uid;
twitter_account_save($twitter_account, TRUE);
drupal_set_message(t('Twitter account added successfully'));
} catch (TwitterException $e) {
form_set_error('screen_name', t('Request failed: @message.', array(
'@message' => $e
->getMessage(),
)));
return;
}
$form['#programmed'] = FALSE;
$form_state['redirect'] = $form_state['twitter_oauth']['destination'];
}