add rate limit call so spaz will work

This commit is contained in:
Friendika 2011-06-20 17:16:13 -07:00
parent 285d617569
commit db336929cd
2 changed files with 22 additions and 1 deletions

View file

@ -129,7 +129,8 @@
break; break;
case "json": case "json":
header ("Content-Type: application/json"); header ("Content-Type: application/json");
return json_encode($r); foreach($r as $rr)
return json_encode($rr);
break; break;
case "rss": case "rss":
header ("Content-Type: application/rss+xml"); header ("Content-Type: application/rss+xml");
@ -279,6 +280,7 @@
* load api $templatename for $type and replace $data array * load api $templatename for $type and replace $data array
*/ */
function api_apply_template($templatename, $type, $data){ function api_apply_template($templatename, $type, $data){
switch($type){ switch($type){
case "rss": case "rss":
case "atom": case "atom":
@ -526,3 +528,17 @@
api_register_func('api/statuses/user_timeline','api_statuses_home_timeline', true); api_register_func('api/statuses/user_timeline','api_statuses_home_timeline', true);
# TODO: user_timeline should be profile view # TODO: user_timeline should be profile view
function api_account_rate_limit_status(&$a,$type) {
$hash = array(
'remaining_hits' => (string) 150,
'hourly_limit' => (string) 150,
'reset_time' => datetime_convert('UTC','UTC','now + 1 hour',ATOM_TIME),
'reset_time_in_seconds' => strtotime('now + 1 hour')
);
return api_apply_template('ratelimit', $type, array('$hash' => $hash));
}
api_register_func('api/account/rate_limit_status','api_account_rate_limit_status',true);

View file

@ -0,0 +1,5 @@
<hash>
<remaining-hits type="integer">$hash.remaining_hits</remaining-hits>
<hourly-limit type="integer">$hash.hourly_limit</hourly-limit>
<reset-time type="datetime">$hash.reset_time</reset-time>
</hash>