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');
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
print '{"authorized":true}';
|
print '{"authorized":true}';
|
||||||
} else {
|
} else {
|
||||||
common_user_error("API method not found!", $code=404);
|
common_user_error(_('API method not found!'), $code=404);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit();
|
exit();
|
||||||
@ -54,7 +54,7 @@ class TwitapiaccountAction extends TwitterapiAction {
|
|||||||
|
|
||||||
function end_session($args, $apidata) {
|
function end_session($args, $apidata) {
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error("API method under construction.", $code=501);
|
common_server_error(_('API method under construction.'), $code=501);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,9 +65,8 @@ class TwitapiaccountAction extends TwitterapiAction {
|
|||||||
|
|
||||||
if (!is_null($location) && strlen($location) > 255) {
|
if (!is_null($location) && strlen($location) > 255) {
|
||||||
|
|
||||||
// XXX: But Twitter just truncates and runs with it. -- Zach
|
// XXX: But Twitter just truncates and runs with it. -- Zach
|
||||||
header('HTTP/1.1 406 Not Acceptable');
|
$this->client_error(_('That\'s too long. Max notice size is 255 chars.'), 406, $apidate['content-type']);
|
||||||
print "That's too long. Max notice size is 255 chars.\n";
|
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,13 +105,13 @@ class TwitapiaccountAction extends TwitterapiAction {
|
|||||||
|
|
||||||
function update_delivery_device($args, $apidata) {
|
function update_delivery_device($args, $apidata) {
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error("API method under construction.", $code=501);
|
common_server_error(_('API method under construction.'), $code=501);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function rate_limit_status($args, $apidata) {
|
function rate_limit_status($args, $apidata) {
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error("API method under construction.", $code=501);
|
common_server_error(_('API method under construction.'), $code=501);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,13 +25,13 @@ class TwitapiblocksAction extends TwitterapiAction {
|
|||||||
|
|
||||||
function create($args, $apidata) {
|
function create($args, $apidata) {
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error("API method under construction.", $code=501);
|
common_server_error(_('API method under construction.'), $code=501);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroy($args, $apidata) {
|
function destroy($args, $apidata) {
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error("API method under construction.", $code=501);
|
common_server_error(_('API method under construction.'), $code=501);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,26 +40,26 @@ class Twitapidirect_messagesAction extends TwitterapiAction {
|
|||||||
|
|
||||||
function direct_messages($args, $apidata) {
|
function direct_messages($args, $apidata) {
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error("API method under construction.", $code=501);
|
common_server_error(_('API method under construction.'), $code=501);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function sent($args, $apidata) {
|
function sent($args, $apidata) {
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error("API method under construction.", $code=501);
|
common_server_error(_('API method under construction.'), $code=501);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
# had to change this from "new" to "create" to avoid PHP reserved word
|
# had to change this from "new" to "create" to avoid PHP reserved word
|
||||||
function create($args, $apidata) {
|
function create($args, $apidata) {
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error("API method under construction.", $code=501);
|
common_server_error(_('API method under construction.'), $code=501);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroy($args, $apidata) {
|
function destroy($args, $apidata) {
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error("API method under construction.", $code=501);
|
common_server_error(_('API method under construction.'), $code=501);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,19 +38,19 @@ class TwitapifavoritesAction extends TwitterapiAction {
|
|||||||
|
|
||||||
function favorites($args, $apidata) {
|
function favorites($args, $apidata) {
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error("API method under construction.", $code=501);
|
common_server_error(_('API method under construction.'), $code=501);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function create($args, $apidata) {
|
function create($args, $apidata) {
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error("API method under construction.", $code=501);
|
common_server_error(_('API method under construction.'), $code=501);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroy($args, $apidata) {
|
function destroy($args, $apidata) {
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error("API method under construction.", $code=501);
|
common_server_error(_('API method under construction.'), $code=501);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,8 @@ class TwitapifriendshipsAction extends TwitterapiAction {
|
|||||||
$user = $apidata['user'];
|
$user = $apidata['user'];
|
||||||
|
|
||||||
if ($user->isSubscribed($other)) {
|
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();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +68,8 @@ class TwitapifriendshipsAction extends TwitterapiAction {
|
|||||||
$result = $sub->insert();
|
$result = $sub->insert();
|
||||||
|
|
||||||
if (!$result) {
|
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();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,14 +42,14 @@ class TwitapihelpAction extends TwitterapiAction {
|
|||||||
print '"ok"';
|
print '"ok"';
|
||||||
$this->end_document('json');
|
$this->end_document('json');
|
||||||
} else {
|
} else {
|
||||||
common_user_error("API method not found!", $code=404);
|
common_user_error(_('API method not found!'), $code=404);
|
||||||
}
|
}
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function downtime_schedule($args, $apidata) {
|
function downtime_schedule($args, $apidata) {
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error("API method under construction.", $code=501);
|
common_server_error(_('API method under construction.'), $code=501);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,13 +26,13 @@ class TwitapinotificationsAction extends TwitterapiAction {
|
|||||||
|
|
||||||
function follow($args, $apidata) {
|
function follow($args, $apidata) {
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error("API method under construction.", $code=501);
|
common_server_error(_('API method under construction.'), $code=501);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function leave($args, $apidata) {
|
function leave($args, $apidata) {
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error("API method under construction.", $code=501);
|
common_server_error(_('API method under construction.'), $code=501);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,12 +82,12 @@ class TwitapistatusesAction extends TwitterapiAction {
|
|||||||
$this->show_json_timeline($notice);
|
$this->show_json_timeline($notice);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
common_user_error("API method not found!", $code = 404);
|
common_user_error(_('API method not found!'), $code = 404);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
common_server_error('Couldn\'t find any statuses.', $code = 503);
|
common_server_error(_('Couldn\'t find any statuses.'), $code = 503);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit();
|
exit();
|
||||||
@ -253,7 +253,7 @@ class TwitapistatusesAction extends TwitterapiAction {
|
|||||||
$this->show_json_timeline($notice);
|
$this->show_json_timeline($notice);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
common_user_error("API method not found!", $code = 404);
|
common_user_error(_('API method not found!'), $code = 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit();
|
exit();
|
||||||
@ -364,7 +364,7 @@ class TwitapistatusesAction extends TwitterapiAction {
|
|||||||
$this->show_json_timeline($notice);
|
$this->show_json_timeline($notice);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
common_user_error("API method not found!", $code = 404);
|
common_user_error(_('API method not found!'), $code = 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit();
|
exit();
|
||||||
@ -397,7 +397,7 @@ class TwitapistatusesAction extends TwitterapiAction {
|
|||||||
// as "truncated." Sending this error may screw up some clients
|
// as "truncated." Sending this error may screw up some clients
|
||||||
// that assume Twitter will truncate for them. Should we just
|
// that assume Twitter will truncate for them. Should we just
|
||||||
// truncate too? -- Zach
|
// 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();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,7 +411,7 @@ class TwitapistatusesAction extends TwitterapiAction {
|
|||||||
if ($reply) {
|
if ($reply) {
|
||||||
$reply_to = $in_reply_to_status_id;
|
$reply_to = $in_reply_to_status_id;
|
||||||
} else {
|
} else {
|
||||||
$this->client_error('Not found', $code = 404, $apidata['content-type']);
|
$this->client_error(_('Not found'), $code = 404, $apidata['content-type']);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -521,7 +521,7 @@ class TwitapistatusesAction extends TwitterapiAction {
|
|||||||
$this->show_json_timeline($notices);
|
$this->show_json_timeline($notices);
|
||||||
break;
|
break;
|
||||||
default:
|
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) {
|
function destroy($args, $apidata) {
|
||||||
|
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
common_server_error("API method under construction.", $code=501);
|
common_server_error("API method under construction.", $code=501);
|
||||||
}
|
}
|
||||||
@ -702,7 +703,7 @@ class TwitapistatusesAction extends TwitterapiAction {
|
|||||||
*/
|
*/
|
||||||
function featured($args, $apidata) {
|
function featured($args, $apidata) {
|
||||||
parent::handle($args);
|
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) {
|
function get_user($id, $apidata) {
|
||||||
@ -716,4 +717,3 @@ class TwitapistatusesAction extends TwitterapiAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ class TwitapiusersAction extends TwitterapiAction {
|
|||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
// XXX: Twitter returns a random(?) user instead of throwing and err! -- Zach
|
// 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();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ class TwitapiusersAction extends TwitterapiAction {
|
|||||||
$this->show_twitter_json_users($twitter_user);
|
$this->show_twitter_json_users($twitter_user);
|
||||||
$this->end_document('json');
|
$this->end_document('json');
|
||||||
} else {
|
} else {
|
||||||
common_user_error("API method not found!", $code = 404);
|
common_user_error(_('API method not found!'), $code = 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit();
|
exit();
|
||||||
|
@ -245,7 +245,7 @@ class TwitterapiAction extends Action {
|
|||||||
$this->init_twitter_atom();
|
$this->init_twitter_atom();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->client_error(_('Unsupported type'));
|
$this->client_error(_('Not a supported data format.'));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ class TwitterapiAction extends Action {
|
|||||||
$this->end_twitter_rss();
|
$this->end_twitter_rss();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->client_error(_('Unsupported type'));
|
$this->client_error(_('Not a supported data format.'));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -351,7 +351,7 @@ class TwitterapiAction extends Action {
|
|||||||
$this->show_twitter_json_users($profile_array);
|
$this->show_twitter_json_users($profile_array);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->client_error(_('not a supported data format'));
|
$this->client_error(_('Not a supported data format.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user