You are here

function twitter_oauth_callback_submit in Twitter 6.3

Same name and namespace in other branches
  1. 6.5 twitter.pages.inc \twitter_oauth_callback_submit()
  2. 6.4 twitter.pages.inc \twitter_oauth_callback_submit()

Implements hook_form_FORM_ID_submit()

Attaches a Twitter account to a Drupal user.

File

./twitter.pages.inc, line 380

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 TwitterOAuth($key, $secret, $response['oauth_token'], $response['oauth_token_secret']);
  $twitter_account = $twitter
    ->users_show($response['screen_name']);
  $twitter_account
    ->set_auth($response);
  $account = $form_state['twitter_oauth']['account'];
  twitter_account_save($twitter_account, TRUE, $account);
  $form_state['redirect'] = $form_state['twitter_oauth']['destination'];
  $form['#programmed'] = FALSE;
}