TwitterBridge messing about, Twitter OAuth requires Authorization header now?

https://dev.twitter.com/oauth/reference/post/oauth/request_token says that
the request should be a GET with a specific HTTP header instead of query
string parameters for OAuth?
This commit is contained in:
Mikael Nordfeldth 2015-07-17 18:44:09 +02:00
parent 5933056a5b
commit 6cd7a4a400
8 changed files with 131 additions and 226 deletions

View File

@ -124,11 +124,11 @@ class Foreign_link extends Managed_DataObject
$fuser->limit(1); $fuser->limit(1);
if ($fuser->find(true)) { if (!$fuser->find(true)) {
return $fuser; throw new NoResultException($fuser);
} }
return null; return $fuser;
} }
function getUser() function getUser()

View File

@ -42,32 +42,33 @@ class Foreign_user extends Managed_DataObject
} }
static function getForeignUser($id, $service) { static function getForeignUser($id, $service) {
$fuser = new Foreign_user(); $fuser = new Foreign_user();
$fuser->id = $id; $fuser->id = $id;
$fuser->service = $service; $fuser->service = $service;
$fuser->limit(1); $fuser->limit(1);
$result = $fuser->find(true); if (!$fuser->find(true)) {
throw new NoResultException($fuser);
}
return empty($result) ? null : $fuser; return $fuser;
} }
static function getByNickname($nickname, $service) static function getByNickname($nickname, $service)
{ {
if (empty($nickname) || empty($service)) { if (empty($nickname) || empty($service)) {
return null; throw new ServerException('Empty nickname or service for Foreign_user::getByNickname');
} else {
$fuser = new Foreign_user();
$fuser->service = $service;
$fuser->nickname = $nickname;
$fuser->limit(1);
$result = $fuser->find(true);
return empty($result) ? null : $fuser;
} }
$fuser = new Foreign_user();
$fuser->service = $service;
$fuser->nickname = $nickname;
$fuser->limit(1);
if (!$fuser->find(true)) {
throw new NoResultException($fuser);
}
return $fuser;
} }
} }

View File

@ -918,12 +918,9 @@ class Facebookclient
static function addFacebookUser($fbuser) static function addFacebookUser($fbuser)
{ {
// remove any existing, possibly outdated, record // remove any existing, possibly outdated, record
$luser = Foreign_user::getForeignUser($fbuser->id, FACEBOOK_SERVICE); try {
$fuser = Foreign_user::getForeignUser($fbuser->id, FACEBOOK_SERVICE);
if (!empty($luser)) { $result = $fuser->delete();
$result = $luser->delete();
if ($result != false) { if ($result != false) {
common_log( common_log(
LOG_INFO, LOG_INFO,
@ -935,6 +932,8 @@ class Facebookclient
__FILE__ __FILE__
); );
} }
} catch (NoResultException $e) {
// no old foreign users exist for this id
} }
$fuser = new Foreign_user(); $fuser = new Foreign_user();

View File

@ -26,9 +26,7 @@
* @link http://status.net/ * @link http://status.net/
*/ */
if (!defined('STATUSNET')) { if (!defined('GNUSOCIAL')) { exit(1); }
exit(1);
}
require_once __DIR__ . '/twitter.php'; require_once __DIR__ . '/twitter.php';
@ -387,12 +385,11 @@ class TwitterBridgePlugin extends Plugin
{ {
$n2s = Notice_to_status::getKV('notice_id', $notice->id); $n2s = Notice_to_status::getKV('notice_id', $notice->id);
if (!empty($n2s)) { if ($n2s instanceof Notice_to_status) {
$flink = Foreign_link::getByUserID($notice->profile_id, $flink = Foreign_link::getByUserID($notice->profile_id, TWITTER_SERVICE); // twitter service
TWITTER_SERVICE); // twitter service
if (empty($flink)) { if (!$flink instanceof Foreign_link) {
return true; return true;
} }
@ -424,15 +421,14 @@ class TwitterBridgePlugin extends Plugin
*/ */
function onEndFavorNotice(Profile $profile, Notice $notice) function onEndFavorNotice(Profile $profile, Notice $notice)
{ {
$flink = Foreign_link::getByUserID($profile->id, $flink = Foreign_link::getByUserID($profile->getID(), TWITTER_SERVICE); // twitter service
TWITTER_SERVICE); // twitter service
if (empty($flink)) { if (!$flink instanceof Foreign_link) {
return true; return true;
} }
if (!TwitterOAuthClient::isPackedToken($flink->credentials)) { if (!TwitterOAuthClient::isPackedToken($flink->credentials)) {
$this->log(LOG_INFO, "Skipping fave processing for {$profile->id} since link is not OAuth."); $this->log(LOG_INFO, "Skipping fave processing for {$profile->getID()} since link is not OAuth.");
return true; return true;
} }

View File

@ -28,7 +28,7 @@
* @link http://status.net/ * @link http://status.net/
*/ */
if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); } if (!defined('GNUSOCIAL')) { exit(1); }
require_once dirname(__DIR__) . '/twitter.php'; require_once dirname(__DIR__) . '/twitter.php';
@ -48,7 +48,7 @@ require_once dirname(__DIR__) . '/twitter.php';
* @link http://status.net/ * @link http://status.net/
* *
*/ */
class TwitterauthorizationAction extends Action class TwitterauthorizationAction extends FormAction
{ {
var $twuid = null; var $twuid = null;
var $tw_fields = null; var $tw_fields = null;
@ -56,112 +56,80 @@ class TwitterauthorizationAction extends Action
var $signin = null; var $signin = null;
var $verifier = null; var $verifier = null;
/** protected $needLogin = false; // authorization page can also be used to create a new user
* Initialize class members. Looks for 'oauth_token' parameter.
*
* @param array $args misc. arguments
*
* @return boolean true
*/
function prepare($args)
{
parent::prepare($args);
protected function doPreparation()
{
$this->signin = $this->boolean('signin'); $this->signin = $this->boolean('signin');
$this->oauth_token = $this->arg('oauth_token'); $this->oauth_token = $this->arg('oauth_token');
$this->verifier = $this->arg('oauth_verifier'); $this->verifier = $this->arg('oauth_verifier');
return true; if ($this->scoped instanceof Profile) {
} $flink = Foreign_link::getByUserID($this->scoped->getID(), TWITTER_SERVICE);
/**
* Handler method
*
* @param array $args is ignored since it's now passed in in prepare()
*
* @return nothing
*/
function handle($args)
{
parent::handle($args);
if (common_logged_in()) {
$user = common_current_user();
$flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE);
// If there's already a foreign link record and a foreign user // If there's already a foreign link record and a foreign user
// it means the accounts are already linked, and this is unecessary. // it means the accounts are already linked, and this is unecessary.
// So go back. // So go back.
if (isset($flink)) { if ($flink instanceof Foreign_link) {
$fuser = $flink->getForeignUser(); try {
if (!empty($fuser)) { $fuser = $flink->getForeignUser();
common_redirect(common_local_url('twittersettings')); common_redirect(common_local_url('twittersettings'));
} catch (NoResultException $e) {
// ok, so no foreign user but there's a foreign link??
// this logic is left since the StatusNet days
} }
} }
} }
if ($_SERVER['REQUEST_METHOD'] == 'POST') { // $this->oauth_token is only populated once Twitter authorizes our
// request token. If it's empty we're at the beginning of the auth
// User was not logged in to StatusNet before // process
if (empty($this->oauth_token)) {
$this->twuid = $this->trimmed('twuid'); // authorizeRequestToken either throws an exception or redirects
$this->authorizeRequestToken();
$this->tw_fields = array('screen_name' => $this->trimmed('tw_fields_screen_name'),
'fullname' => $this->trimmed('tw_fields_fullname'));
$this->access_token = new OAuthToken($this->trimmed('access_token_key'), $this->trimmed('access_token_secret'));
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given.
$this->showForm(_m('There was a problem with your session token. Try again, please.'));
return;
}
if ($this->arg('create')) {
if (!$this->boolean('license')) {
// TRANS: Form validation error displayed when the checkbox to agree to the license has not been checked.
$this->showForm(_m('You cannot register if you do not agree to the license.'),
$this->trimmed('newname'));
return;
}
$this->createNewUser();
} else if ($this->arg('connect')) {
$this->connectNewUser();
} else {
common_debug('Twitter bridge - ' . print_r($this->args, true));
// TRANS: Form validation error displayed when an unhandled error occurs.
$this->showForm(_m('Something weird happened.'),
$this->trimmed('newname'));
}
} else { } else {
// $this->oauth_token is only populated once Twitter authorizes our $this->saveAccessToken();
// request token. If it's empty we're at the beginning of the auth
// process
if (empty($this->oauth_token)) {
$this->authorizeRequestToken();
} else {
$this->saveAccessToken();
}
} }
} }
protected function doPost()
{
// User was not logged in to StatusNet before
$this->twuid = $this->trimmed('twuid');
$this->tw_fields = array('screen_name' => $this->trimmed('tw_fields_screen_name'),
'fullname' => $this->trimmed('tw_fields_fullname'));
$this->access_token = new OAuthToken($this->trimmed('access_token_key'), $this->trimmed('access_token_secret'));
if ($this->arg('create')) {
if (!$this->boolean('license')) {
// TRANS: Form validation error displayed when the checkbox to agree to the license has not been checked.
throw new ClientException(_m('You cannot register if you do not agree to the license.'));
}
return $this->createNewUser();
} else if ($this->arg('connect')) {
return $this->connectNewUser();
}
common_debug('Twitter bridge - ' . print_r($this->args, true));
// TRANS: Form validation error displayed when an unhandled error occurs.
throw new ClientException(_m('No known action for POST.'));
}
/** /**
* Asks Twitter for a request token, and then redirects to Twitter * Asks Twitter for a request token, and then redirects to Twitter
* to authorize it. * to authorize it.
*
* @return nothing
*/ */
function authorizeRequestToken() protected function authorizeRequestToken()
{ {
try { try {
// Get a new request token and authorize it // Get a new request token and authorize it
$client = new TwitterOAuthClient(); $client = new TwitterOAuthClient();
$req_tok = $client->getRequestToken(); $req_tok = $client->getTwitterRequestToken();
// Sock the request token away in the session temporarily // Sock the request token away in the session temporarily
@ -176,10 +144,8 @@ class TwitterauthorizationAction extends Action
$e->getMessage() $e->getMessage()
); );
common_log(LOG_INFO, 'Twitter bridge - ' . $msg); common_log(LOG_INFO, 'Twitter bridge - ' . $msg);
$this->serverError( // TRANS: Server error displayed when linking to a Twitter account fails.
// TRANS: Server error displayed when linking to a Twitter account fails. throw new ServerException(_m('Could not link your Twitter account.'));
_m('Could not link your Twitter account.')
);
} }
common_redirect($auth_link); common_redirect($auth_link);
@ -197,10 +163,8 @@ class TwitterauthorizationAction extends Action
// token we sent them // token we sent them
if ($_SESSION['twitter_request_token'] != $this->oauth_token) { if ($_SESSION['twitter_request_token'] != $this->oauth_token) {
$this->serverError( // TRANS: Server error displayed when linking to a Twitter account fails because of an incorrect oauth_token.
// TRANS: Server error displayed when linking to a Twitter account fails because of an incorrect oauth_token. throw new ServerException(_m('Could not link your Twitter account: oauth_token mismatch.'));
_m('Could not link your Twitter account: oauth_token mismatch.')
);
} }
$twitter_user = null; $twitter_user = null;
@ -212,7 +176,7 @@ class TwitterauthorizationAction extends Action
// Exchange the request token for an access token // Exchange the request token for an access token
$atok = $client->getAccessToken($this->verifier); $atok = $client->getTwitterAccessToken($this->verifier);
// Test the access token and get the user's Twitter info // Test the access token and get the user's Twitter info
@ -235,8 +199,7 @@ class TwitterauthorizationAction extends Action
if (common_logged_in()) { if (common_logged_in()) {
// Save the access token and Twitter user info // Save the access token and Twitter user info
$user = common_current_user(); $this->saveForeignLink($this->scoped->getID(), $twitter_user->id, $atok);
$this->saveForeignLink($user->id, $twitter_user->id, $atok);
save_twitter_user($twitter_user->id, $twitter_user->screen_name); save_twitter_user($twitter_user->id, $twitter_user->screen_name);
} else { } else {
@ -297,24 +260,20 @@ class TwitterauthorizationAction extends Action
$flink_id = $flink->insert(); $flink_id = $flink->insert();
// We want to make sure we got a numerical >0 value, not just failed the insert (which would be === false)
if (empty($flink_id)) { if (empty($flink_id)) {
common_log_db_error($flink, 'INSERT', __FILE__); common_log_db_error($flink, 'INSERT', __FILE__);
// TRANS: Server error displayed when linking to a Twitter account fails. // TRANS: Server error displayed when linking to a Twitter account fails.
$this->serverError(_m('Could not link your Twitter account.')); throw new ServerException(_m('Could not link your Twitter account.'));
} }
return $flink_id; return $flink_id;
} }
function showPageNotice() function getInstructions()
{ {
if ($this->error) { // TRANS: Page instruction. %s is the StatusNet sitename.
$this->element('div', array('class' => 'error'), $this->error); return sprintf(_m('This is the first time you have logged into %s so we must connect your Twitter account to a local account. You can either create a new account, or connect with your existing account, if you have one.'), common_config('site', 'name'));
} else {
$this->element('div', 'instructions',
// TRANS: Page instruction. %s is the StatusNet sitename.
sprintf(_m('This is the first time you have logged into %s so we must connect your Twitter account to a local account. You can either create a new account, or connect with your existing account, if you have one.'), common_config('site', 'name')));
}
} }
function title() function title()
@ -323,19 +282,6 @@ class TwitterauthorizationAction extends Action
return _m('Twitter Account Setup'); return _m('Twitter Account Setup');
} }
function showForm($error=null, $username=null)
{
$this->error = $error;
$this->username = $username;
$this->showPage();
}
function showPage()
{
parent::showPage();
}
/** /**
* @fixme much of this duplicates core code, which is very fragile. * @fixme much of this duplicates core code, which is very fragile.
* Should probably be replaced with an extensible mini version of * Should probably be replaced with an extensible mini version of
@ -380,7 +326,7 @@ class TwitterauthorizationAction extends Action
$this->elementStart('li'); $this->elementStart('li');
// TRANS: Field label. // TRANS: Field label.
$this->input('newname', _m('New nickname'), $this->input('newname', _m('New nickname'),
($this->username) ? $this->username : '', $this->username ?: '',
// TRANS: Field title for nickname field. // TRANS: Field title for nickname field.
_m('1-64 lowercase letters or numbers, no punctuation or spaces.')); _m('1-64 lowercase letters or numbers, no punctuation or spaces.'));
$this->elementEnd('li'); $this->elementEnd('li');
@ -488,12 +434,13 @@ class TwitterauthorizationAction extends Action
function createNewUser() function createNewUser()
{ {
if (!Event::handle('StartRegistrationTry', array($this))) { if (!Event::handle('StartRegistrationTry', array($this))) {
return; // TRANS: Client error displayed when trying to create a new user but a plugin aborted the process.
throw new ClientException(_m('Registration of new user was aborted, maybe you failed a captcha?'));
} }
if (common_config('site', 'closed')) { if (common_config('site', 'closed')) {
// TRANS: Client error displayed when trying to create a new user while creating new users is not allowed. // TRANS: Client error displayed when trying to create a new user while creating new users is not allowed.
$this->clientError(_m('Registration not allowed.')); throw new ClientException(_m('Registration not allowed.'));
} }
$invite = null; $invite = null;
@ -502,23 +449,19 @@ class TwitterauthorizationAction extends Action
$code = $_SESSION['invitecode']; $code = $_SESSION['invitecode'];
if (empty($code)) { if (empty($code)) {
// TRANS: Client error displayed when trying to create a new user while creating new users is not allowed. // TRANS: Client error displayed when trying to create a new user while creating new users is not allowed.
$this->clientError(_m('Registration not allowed.')); throw new ClientException(_m('Registration not allowed.'));
} }
$invite = Invitation::getKV($code); $invite = Invitation::getKV('code', $code);
if (empty($invite)) { if (!$invite instanceof Invite) {
// TRANS: Client error displayed when trying to create a new user with an invalid invitation code. // TRANS: Client error displayed when trying to create a new user with an invalid invitation code.
$this->clientError(_m('Not a valid invitation code.')); throw new ClientException(_m('Not a valid invitation code.'));
} }
} }
try { // Nickname::normalize throws exception if the nickname is taken
$nickname = Nickname::normalize($this->trimmed('newname'), true); $nickname = Nickname::normalize($this->trimmed('newname'), true);
} catch (NicknameException $e) {
$this->showForm($e->getMessage());
return;
}
$fullname = trim($this->tw_fields['fullname']); $fullname = trim($this->tw_fields['fullname']);
@ -533,23 +476,14 @@ class TwitterauthorizationAction extends Action
$args['email'] = $email; $args['email'] = $email;
} }
try { $user = User::register($args);
$user = User::register($args);
} catch (Exception $e) {
$this->serverError($e->getMessage());
}
$result = $this->saveForeignLink($user->id, $this->saveForeignLink($user->id,
$this->twuid, $this->twuid,
$this->access_token); $this->access_token);
save_twitter_user($this->twuid, $this->tw_fields['screen_name']); save_twitter_user($this->twuid, $this->tw_fields['screen_name']);
if (!$result) {
// TRANS: Server error displayed when connecting a user to a Twitter user has failed.
$this->serverError(_m('Error connecting user to Twitter.'));
}
common_set_user($user); common_set_user($user);
common_real_login(true); common_real_login(true);
@ -569,28 +503,23 @@ class TwitterauthorizationAction extends Action
if (!common_check_user($nickname, $password)) { if (!common_check_user($nickname, $password)) {
// TRANS: Form validation error displayed when connecting an existing user to a Twitter user fails because // TRANS: Form validation error displayed when connecting an existing user to a Twitter user fails because
// TRANS: the provided username and/or password are incorrect. // TRANS: the provided username and/or password are incorrect.
$this->showForm(_m('Invalid username or password.')); throw new ClientException(_m('Invalid username or password.'));
return;
} }
$user = User::getKV('nickname', $nickname); $user = User::getKV('nickname', $nickname);
if (!empty($user)) { if ($user instanceof User) {
common_debug('TwitterBridge Plugin - ' . common_debug('TwitterBridge Plugin - ' .
"Legit user to connect to Twitter: $nickname"); "Legit user to connect to Twitter: $nickname");
} }
$result = $this->saveForeignLink($user->id, // throws exception on failure
$this->twuid, $this->saveForeignLink($user->id,
$this->access_token); $this->twuid,
$this->access_token);
save_twitter_user($this->twuid, $this->tw_fields['screen_name']); save_twitter_user($this->twuid, $this->tw_fields['screen_name']);
if (!$result) {
// TRANS: Server error displayed connecting a user to a Twitter user has failed.
$this->serverError(_m('Error connecting user to Twitter.'));
}
common_debug('TwitterBridge Plugin - ' . common_debug('TwitterBridge Plugin - ' .
"Connected Twitter user $this->twuid to local user $user->id"); "Connected Twitter user $this->twuid to local user $user->id");

View File

@ -28,9 +28,7 @@
* @link http://status.net/ * @link http://status.net/
*/ */
if (!defined('STATUSNET') && !defined('LACONICA')) { if (!defined('GNUSOCIAL')) { exit(1); }
exit(1);
}
require_once dirname(__DIR__) . '/twitter.php'; require_once dirname(__DIR__) . '/twitter.php';
@ -46,20 +44,8 @@ require_once dirname(__DIR__) . '/twitter.php';
* *
* @see SettingsAction * @see SettingsAction
*/ */
class TwitterloginAction extends Action class TwitterloginAction extends LoginAction
{ {
function handle($args)
{
parent::handle($args);
if (common_is_real_login()) {
// TRANS: Client error displayed when trying to log in using Twitter while already logged in to StatusNet.
$this->clientError(_m('Already logged in.'));
}
$this->showPage();
}
function title() function title()
{ {
// TRANS: Title for login using Twitter page. // TRANS: Title for login using Twitter page.
@ -72,15 +58,6 @@ class TwitterloginAction extends Action
return _m('Login with your Twitter account'); return _m('Login with your Twitter account');
} }
function showPageNotice()
{
$instr = $this->getInstructions();
$output = common_markup_to_html($instr);
$this->elementStart('div', 'instructions');
$this->raw($output);
$this->elementEnd('div');
}
function showContent() function showContent()
{ {
$this->elementStart('a', array('href' => common_local_url('twitterauthorization', $this->elementStart('a', array('href' => common_local_url('twitterauthorization',

View File

@ -111,7 +111,7 @@ class TwitterOAuthClient extends OAuthClient
* *
* @return OAuthToken $token the request token * @return OAuthToken $token the request token
*/ */
function getRequestToken() function getTwitterRequestToken()
{ {
return parent::getRequestToken( return parent::getRequestToken(
self::$requestTokenURL, self::$requestTokenURL,
@ -142,7 +142,7 @@ class TwitterOAuthClient extends OAuthClient
* *
* @return OAuthToken $token the access token * @return OAuthToken $token the access token
*/ */
function getAccessToken($verifier = null) function getTwitterAccessToken($verifier = null)
{ {
return parent::getAccessToken( return parent::getAccessToken(
self::$accessTokenURL, self::$accessTokenURL,

View File

@ -28,16 +28,17 @@ function add_twitter_user($twitter_id, $screen_name)
// Clear out any bad old foreign_users with the new user's legit URL // Clear out any bad old foreign_users with the new user's legit URL
// This can happen when users move around or fakester accounts get // This can happen when users move around or fakester accounts get
// repoed, and things like that. // repoed, and things like that.
$luser = Foreign_user::getForeignUser($twitter_id, TWITTER_SERVICE); try {
$fuser = Foreign_user::getForeignUser($twitter_id, TWITTER_SERVICE);
if (!empty($luser)) { $result = $fuser->delete();
$result = $luser->delete();
if ($result != false) { if ($result != false) {
common_log( common_log(
LOG_INFO, LOG_INFO,
"Twitter bridge - removed old Twitter user: $screen_name ($twitter_id)." "Twitter bridge - removed old Twitter user: $screen_name ($twitter_id)."
); );
} }
} catch (NoResultException $e) {
// no old foreign users exist for this id
} }
$fuser = new Foreign_user(); $fuser = new Foreign_user();
@ -49,9 +50,8 @@ function add_twitter_user($twitter_id, $screen_name)
$fuser->created = common_sql_now(); $fuser->created = common_sql_now();
$result = $fuser->insert(); $result = $fuser->insert();
if (empty($result)) { if ($result === false) {
common_log(LOG_WARNING, common_log(LOG_WARNING, "Twitter bridge - failed to add new Twitter user: $twitter_id - $screen_name.");
"Twitter bridge - failed to add new Twitter user: $twitter_id - $screen_name.");
common_log_db_error($fuser, 'INSERT', __FILE__); common_log_db_error($fuser, 'INSERT', __FILE__);
} else { } else {
common_log(LOG_INFO, common_log(LOG_INFO,
@ -66,11 +66,10 @@ function save_twitter_user($twitter_id, $screen_name)
{ {
// Check to see whether the Twitter user is already in the system, // Check to see whether the Twitter user is already in the system,
// and update its screen name and uri if so. // and update its screen name and uri if so.
$fuser = Foreign_user::getForeignUser($twitter_id, TWITTER_SERVICE); try {
$fuser = Foreign_user::getForeignUser($twitter_id, TWITTER_SERVICE);
if (!empty($fuser)) {
// Delete old record if Twitter user changed screen name // Delete old record if Twitter user changed screen name
if ($fuser->nickname != $screen_name) { if ($fuser->nickname != $screen_name) {
$oldname = $fuser->nickname; $oldname = $fuser->nickname;
$fuser->delete(); $fuser->delete();
@ -80,11 +79,13 @@ function save_twitter_user($twitter_id, $screen_name)
$screen_name, $screen_name,
$oldname)); $oldname));
} }
} else { } catch (NoResultException $e) {
// No old users exist for this id
// Kill any old, invalid records for this screen name // Kill any old, invalid records for this screen name
$fuser = Foreign_user::getByNickname($screen_name, TWITTER_SERVICE); // XXX: Is this really only supposed to be run if the above getForeignUser fails?
try {
if (!empty($fuser)) { $fuser = Foreign_user::getByNickname($screen_name, TWITTER_SERVICE);
$fuser->delete(); $fuser->delete();
common_log( common_log(
LOG_INFO, LOG_INFO,
@ -95,6 +96,8 @@ function save_twitter_user($twitter_id, $screen_name)
$fuser->id $fuser->id
) )
); );
} catch (NoResultException $e) {
// No old users exist for this screen_name
} }
} }