diff options
author | zach <zach@controlyourself.ca> | 2008-10-16 22:36:38 -0400 |
---|---|---|
committer | zach <zach@controlyourself.ca> | 2008-10-16 22:36:38 -0400 |
commit | b2f0ad1cccc4bebbf264c4ab61a37173c9a565cc (patch) | |
tree | e0b7298a79dbd44710b385a4fdc5eac2f4785aa8 /actions/twitapifavorites.php | |
parent | 9b75a8ea9f7f274e1e410afa3f3cde793bdecdc3 (diff) |
Twitter-compatible API:
- Filled in favorites tags in statuses
- Filled in more tags in user/show, including undocumented features
- Better error handling and more consistent error messages
- Code clean-up and refactoring
- Removed huge obnoxious comments
darcs-hash:20081017023638-462f3-27b5d2709e423c616723d4bcfbc9d7d30a4ad161.gz
Diffstat (limited to 'actions/twitapifavorites.php')
-rw-r--r-- | actions/twitapifavorites.php | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/actions/twitapifavorites.php b/actions/twitapifavorites.php index a327cddb4..2c6c2e1d9 100644 --- a/actions/twitapifavorites.php +++ b/actions/twitapifavorites.php @@ -39,27 +39,12 @@ class TwitapifavoritesAction extends TwitterapiAction { function favorites($args, $apidata) { parent::handle($args); - $user = null; - - // function was called with an argument /favorites/api_arg.format - if (isset($apidata['api_arg'])) { - - if (is_numeric($apidata['api_arg'])) { - $user = User::staticGet($apidata['api_arg']); - } else { - $nickname = common_canonical_nickname($apidata['api_arg']); - $user = User::staticGet('nickname', $nickname); - } - } else { - - // if no user was specified, then we'll use the authenticated user - $user = $apidata['user']; - } + $this->auth_user = $apidata['user']; + $user = $this->get_user($apidata['api_arg'], $apidata); if (!$user) { - // Set the user to be the auth user if asked-for can't be found - // honestly! This is what Twitter does, I swear --Zach - $user = $apidata['user']; + $this->client_error('Not Found', 404, $apidata['content-type']); + return; } $profile = $user->getProfile(); @@ -116,11 +101,6 @@ class TwitapifavoritesAction extends TwitterapiAction { function create($args, $apidata) { parent::handle($args); - if (!in_array($apidata['content-type'], array('xml', 'json'))) { - common_user_error(_('API method not found!'), $code = 404); - return; - } - // Check for RESTfulness if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) { // XXX: Twitter just prints the err msg, no XML / JSON. @@ -128,7 +108,13 @@ class TwitapifavoritesAction extends TwitterapiAction { return; } - $user = $apidata['user']; + if (!in_array($apidata['content-type'], array('xml', 'json'))) { + common_user_error(_('API method not found!'), $code = 404); + return; + } + + $this->auth_user = $apidata['user']; + $user = $this->auth_user; $notice_id = $apidata['api_arg']; $notice = Notice::staticGet($notice_id); |