diff options
author | zach <zach@controlyourself.ca> | 2008-09-30 22:54:21 -0400 |
---|---|---|
committer | zach <zach@controlyourself.ca> | 2008-09-30 22:54:21 -0400 |
commit | 6beddfdbb926aaa5af42e68ff459f11e0e5f6b5f (patch) | |
tree | 9dfa00b3fa201ff6e0848f97a80ebb7bb02a7e0d /actions/twitapiusers.php | |
parent | dec2f29c6a77dd97383ebdbabdc0bff8e524bfa4 (diff) |
Twitter-compatible API - cleaned up sloppy control flow: exit() statements everywhere
darcs-hash:20081001025421-462f3-3bf666327de3a3c5ea506b2c387741dc3d0e82bf.gz
Diffstat (limited to 'actions/twitapiusers.php')
-rw-r--r-- | actions/twitapiusers.php | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/actions/twitapiusers.php b/actions/twitapiusers.php index b43a64152..625a695e3 100644 --- a/actions/twitapiusers.php +++ b/actions/twitapiusers.php @@ -23,11 +23,11 @@ require_once(INSTALLDIR.'/lib/twitterapi.php'); class TwitapiusersAction extends TwitterapiAction { - function is_readonly() { + function is_readonly() { return true; } -/* +/* Returns extended information of a given user, specified by ID or screen name as per the required id parameter below. This information includes design settings, so third party developers can theme their @@ -47,45 +47,45 @@ class TwitapiusersAction extends TwitterapiAction { * email. Optional. The email address of a user. Ex: http://twitter.com/users/show.xml?email=test@example.com -*/ +*/ function show($args, $apidata) { parent::handle($args); - + if (!in_array($apidata['content-type'], array('xml', 'json'))) { common_user_error(_('API method not found!'), $code = 404); - exit; + return; } - + $user = null; $email = $this->arg('email'); - + if (isset($apidata['api_arg'])) { if (is_numeric($apidata['api_arg'])) { // by user id - $user = User::staticGet($apidata['api_arg']); + $user = User::staticGet($apidata['api_arg']); } else { // by nickname $nickname = common_canonical_nickname($apidata['api_arg']); $user = User::staticGet('nickname', $nickname); - } + } } elseif ($email) { // or, find user by email address // XXX: The Twitter API spec say an id is *required*, but you can actually // pull up a user with just an email address. -- Zach - $user = User::staticGet('email', $email); - } + $user = User::staticGet('email', $email); + } if (!$user) { // XXX: Twitter returns a random(?) user instead of throwing and err! -- Zach $this->client_error(_('User not found.'), 404, $apidata['content-type']); - exit(); + return; } - + $profile = $user->getProfile(); if (!$profile) { common_server_error(_('User has no profile.')); - exit(); + return; } $twitter_user = $this->twitter_user_array($profile, true); @@ -115,7 +115,7 @@ class TwitapiusersAction extends TwitterapiAction { $twitter_user['following'] = ''; $twitter_user['notifications'] = ''; - if ($apidata['content-type'] == 'xml') { + if ($apidata['content-type'] == 'xml') { $this->init_document('xml'); $this->show_twitter_xml_user($twitter_user); $this->end_document('xml'); @@ -123,8 +123,7 @@ class TwitapiusersAction extends TwitterapiAction { $this->init_document('json'); $this->show_json_objects($twitter_user); $this->end_document('json'); - } - - exit(); + } + } } |