3 * StatusNet, the distributed open-source microblogging tool
5 * Dummy action that emulates Twitter's rate limit status API resource
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Zach Copley <zach@status.net>
25 * @copyright 2009 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('STATUSNET')) {
34 require_once INSTALLDIR.'/lib/apibareauth.php';
37 * We don't have a rate limit, but some clients check this method.
38 * It always returns the same thing: 100 hits left.
42 * @author Zach Copley <zach@status.net>
43 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
44 * @link http://status.net/
47 class ApiAccountRateLimitStatusAction extends ApiBareAuthAction
53 * Return some Twitter-ish data about API limits
55 * @param array $args $_REQUEST data (unused)
60 function handle($args)
62 parent::handle($args);
64 if (!in_array($this->format, array('xml', 'json'))) {
66 _('API method not found!'),
73 $reset = new DateTime();
74 $reset->modify('+1 hour');
76 $this->init_document($this->format);
78 if ($this->format == 'xml') {
79 $this->elementStart('hash');
80 $this->element('remaining-hits', array('type' => 'integer'), 150);
81 $this->element('hourly-limit', array('type' => 'integer'), 150);
83 'reset-time', array('type' => 'datetime'),
84 common_date_iso8601($reset->format('r'))
87 'reset_time_in_seconds',
88 array('type' => 'integer'),
91 $this->elementEnd('hash');
92 } elseif ($this->format == 'json') {
94 'reset_time_in_seconds' => strtotime('+1 hour'),
95 'remaining_hits' => 150,
96 'hourly_limit' => 150,
97 'reset_time' => common_date_rfc2822(
101 print json_encode($out);
104 $this->end_document($this->format);