Twitter-compatible API - running all strings through gettext() now
darcs-hash:20080819002903-462f3-94e62891db9b9de049a918034742e545f663e840.gz
This commit is contained in:
parent
c2a2da6966
commit
d57bc1b8e9
@ -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();
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user