You are here

function twitter_non_auth_account_form_submit in Twitter 7.5

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

Submit form handler to add a non-authenticated Twitter account.

File

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

Code

function twitter_non_auth_account_form_submit($form, &$form_state) {
  $name = $form_state['values']['screen_name'];
  $twitter = twitter_connect(NULL, TRUE, TRUE);
  if (!$twitter) {
    return FALSE;
  }
  $twitter_account = $twitter
    ->users_show($name, FALSE);
  if (!isset($twitter_account->id)) {
    form_set_error('screen_name', t('Could not add the Twitter account <em>@name</em>. ' . 'Check the recent messages log.', array(
      '@name' => $name,
    )));
  }
  else {
    $twitter_account->uid = $form_state['values']['uid'];
    twitter_account_save($twitter_account, FALSE);
    drupal_set_message(t('Twitter account added successfully'));
  }
}