You are here

function twitter_account_form_submit in Twitter 7.3

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.4 twitter.pages.inc \twitter_account_form_submit()

Implements hook_FORM_ID_submit()

Loads Twitter account details and adds them to the user account

File

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

Code

function twitter_account_form_submit($form, &$form_state) {
  module_load_include('lib.php', 'twitter');
  module_load_include('inc', 'twitter');
  $name = $form_state['values']['screen_name'];
  $twitter = new Twitter($name);
  try {
    $account = $twitter
      ->users_show($name, FALSE);
  } catch (TwitterException $e) {
    form_set_error('screen_name', t('Request failed: @message.', array(
      '@message' => $e
        ->getMessage(),
    )));
    return;
  }
  twitter_account_save($account, TRUE, user_load($form_state['values']['uid']));
}