You are here

function twitter_account_form_submit in Twitter 7.4

Same name and namespace in other branches
  1. 6.3 twitter.pages.inc \twitter_account_form_submit()
  2. 6.4 twitter.pages.inc \twitter_account_form_submit()
  3. 7.3 twitter.pages.inc \twitter_account_form_submit()

Form submit handler for adding a Twiter account.

Loads Twitter account details and adds them to the user account

File

./twitter.pages.inc, line 345
Page callbacks for Twitter module.

Code

function twitter_account_form_submit($form, &$form_state) {
  $key = variable_get('twitter_consumer_key', '');
  $secret = variable_get('twitter_consumer_secret', '');
  $twitter = new Twitter($key, $secret);
  $token = $twitter
    ->get_request_token();
  if ($token) {
    $_SESSION['twitter_oauth']['account'] = user_load($form['uid']['#value']);
    $_SESSION['twitter_oauth']['token'] = $token;
    $_SESSION['twitter_oauth']['destination'] = $_GET['q'];
    drupal_goto($twitter
      ->get_authorize_url($token));
  }
  else {
    drupal_set_message(t('Could not obtain a valid token from the Twitter API. Please review the configuration.'), 'error');
  }
}