From d57bc1b8e99a432d7f6425d0c8836a3c4928581a Mon Sep 17 00:00:00 2001 From: zach Date: Mon, 18 Aug 2008 20:29:03 -0400 Subject: [PATCH] Twitter-compatible API - running all strings through gettext() now darcs-hash:20080819002903-462f3-94e62891db9b9de049a918034742e545f663e840.gz --- actions/twitapiaccount.php | 13 ++++++------- actions/twitapiblocks.php | 4 ++-- actions/twitapidirect_messages.php | 8 ++++---- actions/twitapifavorites.php | 6 +++--- actions/twitapifriendships.php | 6 ++++-- actions/twitapihelp.php | 4 ++-- actions/twitapinotifications.php | 4 ++-- actions/twitapistatuses.php | 18 +++++++++--------- actions/twitapiusers.php | 4 ++-- lib/twitterapi.php | 6 +++--- 10 files changed, 37 insertions(+), 36 deletions(-) diff --git a/actions/twitapiaccount.php b/actions/twitapiaccount.php index 0a57ad91c3..716ddd1543 100644 --- a/actions/twitapiaccount.php +++ b/actions/twitapiaccount.php @@ -46,7 +46,7 @@ class TwitapiaccountAction extends TwitterapiAction { header('Content-Type: application/json; charset=utf-8'); print '{"authorized":true}'; } else { - common_user_error("API method not found!", $code=404); + common_user_error(_('API method not found!'), $code=404); } exit(); @@ -54,7 +54,7 @@ class TwitapiaccountAction extends TwitterapiAction { function end_session($args, $apidata) { parent::handle($args); - common_server_error("API method under construction.", $code=501); + common_server_error(_('API method under construction.'), $code=501); exit(); } @@ -65,9 +65,8 @@ class TwitapiaccountAction extends TwitterapiAction { if (!is_null($location) && strlen($location) > 255) { - // XXX: But Twitter just truncates and runs with it. -- Zach - header('HTTP/1.1 406 Not Acceptable'); - print "That's too long. Max notice size is 255 chars.\n"; + // XXX: But Twitter just truncates and runs with it. -- Zach + $this->client_error(_('That\'s too long. Max notice size is 255 chars.'), 406, $apidate['content-type']); exit(); } @@ -106,13 +105,13 @@ class TwitapiaccountAction extends TwitterapiAction { function update_delivery_device($args, $apidata) { parent::handle($args); - common_server_error("API method under construction.", $code=501); + common_server_error(_('API method under construction.'), $code=501); exit(); } function rate_limit_status($args, $apidata) { parent::handle($args); - common_server_error("API method under construction.", $code=501); + common_server_error(_('API method under construction.'), $code=501); exit(); } } \ No newline at end of file diff --git a/actions/twitapiblocks.php b/actions/twitapiblocks.php index a498d2038d..0fdbba199f 100644 --- a/actions/twitapiblocks.php +++ b/actions/twitapiblocks.php @@ -25,13 +25,13 @@ class TwitapiblocksAction extends TwitterapiAction { function create($args, $apidata) { parent::handle($args); - common_server_error("API method under construction.", $code=501); + common_server_error(_('API method under construction.'), $code=501); exit(); } function destroy($args, $apidata) { parent::handle($args); - common_server_error("API method under construction.", $code=501); + common_server_error(_('API method under construction.'), $code=501); exit(); } diff --git a/actions/twitapidirect_messages.php b/actions/twitapidirect_messages.php index 9a84082e6d..aad055fbf2 100644 --- a/actions/twitapidirect_messages.php +++ b/actions/twitapidirect_messages.php @@ -40,26 +40,26 @@ class Twitapidirect_messagesAction extends TwitterapiAction { function direct_messages($args, $apidata) { parent::handle($args); - common_server_error("API method under construction.", $code=501); + common_server_error(_('API method under construction.'), $code=501); exit(); } function sent($args, $apidata) { parent::handle($args); - common_server_error("API method under construction.", $code=501); + common_server_error(_('API method under construction.'), $code=501); exit(); } # had to change this from "new" to "create" to avoid PHP reserved word function create($args, $apidata) { parent::handle($args); - common_server_error("API method under construction.", $code=501); + common_server_error(_('API method under construction.'), $code=501); exit(); } function destroy($args, $apidata) { parent::handle($args); - common_server_error("API method under construction.", $code=501); + common_server_error(_('API method under construction.'), $code=501); exit(); } diff --git a/actions/twitapifavorites.php b/actions/twitapifavorites.php index 4de5676034..b5380bd948 100644 --- a/actions/twitapifavorites.php +++ b/actions/twitapifavorites.php @@ -38,19 +38,19 @@ class TwitapifavoritesAction extends TwitterapiAction { function favorites($args, $apidata) { parent::handle($args); - common_server_error("API method under construction.", $code=501); + common_server_error(_('API method under construction.'), $code=501); exit(); } function create($args, $apidata) { parent::handle($args); - common_server_error("API method under construction.", $code=501); + common_server_error(_('API method under construction.'), $code=501); exit(); } function destroy($args, $apidata) { parent::handle($args); - common_server_error("API method under construction.", $code=501); + common_server_error(_('API method under construction.'), $code=501); exit(); } diff --git a/actions/twitapifriendships.php b/actions/twitapifriendships.php index 05c192ea6f..ae15d171e7 100644 --- a/actions/twitapifriendships.php +++ b/actions/twitapifriendships.php @@ -52,7 +52,8 @@ class TwitapifriendshipsAction extends TwitterapiAction { $user = $apidata['user']; if ($user->isSubscribed($other)) { - $this->client_error("Could not follow user: $other->nickname is already on your list.", 403, $apidata['content-type']); + $errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname); + $this->client_error($errmsg, 403, $apidata['content-type']); exit(); } @@ -67,7 +68,8 @@ class TwitapifriendshipsAction extends TwitterapiAction { $result = $sub->insert(); if (!$result) { - $this->client_error("Could not follow user: $other->nickname.", 400, $apidata['content-type']); + $errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname); + $this->client_error($errmsg, 400, $apidata['content-type']); exit(); } diff --git a/actions/twitapihelp.php b/actions/twitapihelp.php index 7695190fca..2ac4178de8 100644 --- a/actions/twitapihelp.php +++ b/actions/twitapihelp.php @@ -42,14 +42,14 @@ class TwitapihelpAction extends TwitterapiAction { print '"ok"'; $this->end_document('json'); } else { - common_user_error("API method not found!", $code=404); + common_user_error(_('API method not found!'), $code=404); } exit(); } function downtime_schedule($args, $apidata) { parent::handle($args); - common_server_error("API method under construction.", $code=501); + common_server_error(_('API method under construction.'), $code=501); exit(); } diff --git a/actions/twitapinotifications.php b/actions/twitapinotifications.php index 95fe550b12..9e3cc15c42 100644 --- a/actions/twitapinotifications.php +++ b/actions/twitapinotifications.php @@ -26,13 +26,13 @@ class TwitapinotificationsAction extends TwitterapiAction { function follow($args, $apidata) { parent::handle($args); - common_server_error("API method under construction.", $code=501); + common_server_error(_('API method under construction.'), $code=501); exit(); } function leave($args, $apidata) { parent::handle($args); - common_server_error("API method under construction.", $code=501); + common_server_error(_('API method under construction.'), $code=501); exit(); } diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php index 92c6fbb634..6a63dd0377 100644 --- a/actions/twitapistatuses.php +++ b/actions/twitapistatuses.php @@ -82,12 +82,12 @@ class TwitapistatusesAction extends TwitterapiAction { $this->show_json_timeline($notice); break; default: - common_user_error("API method not found!", $code = 404); + common_user_error(_('API method not found!'), $code = 404); break; } } else { - common_server_error('Couldn\'t find any statuses.', $code = 503); + common_server_error(_('Couldn\'t find any statuses.'), $code = 503); } exit(); @@ -253,7 +253,7 @@ class TwitapistatusesAction extends TwitterapiAction { $this->show_json_timeline($notice); break; default: - common_user_error("API method not found!", $code = 404); + common_user_error(_('API method not found!'), $code = 404); } exit(); @@ -364,7 +364,7 @@ class TwitapistatusesAction extends TwitterapiAction { $this->show_json_timeline($notice); break; default: - common_user_error("API method not found!", $code = 404); + common_user_error(_('API method not found!'), $code = 404); } exit(); @@ -397,7 +397,7 @@ class TwitapistatusesAction extends TwitterapiAction { // as "truncated." Sending this error may screw up some clients // that assume Twitter will truncate for them. Should we just // truncate too? -- Zach - $this->client_error('That\'s too long. Max notice size is 140 chars.', $code = 406, $apidata['content-type']); + $this->client_error(_('That\'s too long. Max notice size is 140 chars.'), $code = 406, $apidata['content-type']); exit(); } @@ -411,7 +411,7 @@ class TwitapistatusesAction extends TwitterapiAction { if ($reply) { $reply_to = $in_reply_to_status_id; } else { - $this->client_error('Not found', $code = 404, $apidata['content-type']); + $this->client_error(_('Not found'), $code = 404, $apidata['content-type']); exit(); } } @@ -521,7 +521,7 @@ class TwitapistatusesAction extends TwitterapiAction { $this->show_json_timeline($notices); break; default: - common_user_error("API method not found!", $code = 404); + common_user_error(_('API method not found!'), $code = 404); } @@ -548,6 +548,7 @@ class TwitapistatusesAction extends TwitterapiAction { */ function destroy($args, $apidata) { + parent::handle($args); common_server_error("API method under construction.", $code=501); } @@ -702,7 +703,7 @@ class TwitapistatusesAction extends TwitterapiAction { */ function featured($args, $apidata) { parent::handle($args); - common_server_error("API method under construction.", $code=501); + common_server_error(_('API method under construction.'), $code=501); } function get_user($id, $apidata) { @@ -716,4 +717,3 @@ class TwitapistatusesAction extends TwitterapiAction { } } - diff --git a/actions/twitapiusers.php b/actions/twitapiusers.php index d66dc88632..233de3c217 100644 --- a/actions/twitapiusers.php +++ b/actions/twitapiusers.php @@ -72,7 +72,7 @@ class TwitapiusersAction extends TwitterapiAction { if (!$user) { // XXX: Twitter returns a random(?) user instead of throwing and err! -- Zach - $this->client_error("User not found.", 404, $apidata['content-type']); + $this->client_error(_('User not found.'), 404, $apidata['content-type']); exit(); } @@ -119,7 +119,7 @@ class TwitapiusersAction extends TwitterapiAction { $this->show_twitter_json_users($twitter_user); $this->end_document('json'); } else { - common_user_error("API method not found!", $code = 404); + common_user_error(_('API method not found!'), $code = 404); } exit(); diff --git a/lib/twitterapi.php b/lib/twitterapi.php index 8b4c24cabc..f06c1d1886 100644 --- a/lib/twitterapi.php +++ b/lib/twitterapi.php @@ -245,7 +245,7 @@ class TwitterapiAction extends Action { $this->init_twitter_atom(); break; default: - $this->client_error(_('Unsupported type')); + $this->client_error(_('Not a supported data format.')); break; } @@ -266,7 +266,7 @@ class TwitterapiAction extends Action { $this->end_twitter_rss(); break; default: - $this->client_error(_('Unsupported type')); + $this->client_error(_('Not a supported data format.')); break; } return; @@ -351,7 +351,7 @@ class TwitterapiAction extends Action { $this->show_twitter_json_users($profile_array); break; default: - $this->client_error(_('not a supported data format')); + $this->client_error(_('Not a supported data format.')); return; } return; -- 2.39.5