123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- if (!defined('GNUSOCIAL')) {
- exit(1);
- }
- class ApiAccountRateLimitStatusAction extends ApiBareAuthAction
- {
-
- public function isReadOnly($args)
- {
- return true;
- }
-
- protected function handle()
- {
- parent::handle();
- if (!in_array($this->format, ['xml', 'json'])) {
- $this->clientError(
-
- _('API method not found.'),
- 404,
- $this->format
- );
- }
- $reset = new DateTime();
- $reset->modify('+1 hour');
- $this->initDocument($this->format);
- if ($this->format == 'xml') {
- $this->elementStart('hash');
- $this->element('remaining-hits', ['type' => 'integer'], "150");
- $this->element('hourly-limit', ['type' => 'integer'], "150");
- $this->element(
- 'reset-time',
- ['type' => 'datetime'],
- common_date_iso8601($reset->format('r'))
- );
- $this->element(
- 'reset_time_in_seconds',
- ['type' => 'integer'],
- strtotime('+1 hour')
- );
- $this->elementEnd('hash');
- } elseif ($this->format == 'json') {
- $out = [
- 'reset_time_in_seconds' => strtotime('+1 hour'),
- 'remaining_hits' => 150,
- 'hourly_limit' => 150,
- 'reset_time' => common_date_rfc2822(
- $reset->format('r')
- )
- ];
- print json_encode($out);
- }
- $this->endDocument($this->format);
- }
- }
|