]> git.mxchange.org Git - friendica.git/commitdiff
add rate limit call so spaz will work
authorFriendika <info@friendika.com>
Tue, 21 Jun 2011 00:16:13 +0000 (17:16 -0700)
committerFriendika <info@friendika.com>
Tue, 21 Jun 2011 00:16:13 +0000 (17:16 -0700)
include/api.php
view/api_ratelimit_xml.tpl [new file with mode: 0644]

index 43a77bcc7a7ecfeb321846e55289f53ae934da9e..2d90071267551fbddb242f22fb1e7c4cac2837e8 100644 (file)
                                                break;
                                        case "json": 
                                                header ("Content-Type: application/json");  
-                                               return json_encode($r);
+                                               foreach($r as $rr)
+                                                   return json_encode($rr);
                                                break;
                                        case "rss":
                                                header ("Content-Type: application/rss+xml");
         *  load api $templatename for $type and replace $data array
         */
        function api_apply_template($templatename, $type, $data){
+
                switch($type){
                        case "rss":
                        case "atom":
        api_register_func('api/statuses/user_timeline','api_statuses_home_timeline', true);
        # 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);
diff --git a/view/api_ratelimit_xml.tpl b/view/api_ratelimit_xml.tpl
new file mode 100644 (file)
index 0000000..42439f8
--- /dev/null
@@ -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>
\ No newline at end of file