/** * compile and send the json response. */ public function afterRoute($f3, $params) { $version = (int) $f3->get('GET.version'); if (empty($version)) { $version = $this->version; } if ($version !== $this->version) { $this->failure(4999, 'Unknown API version requested.', 400); } if (empty($this->data['href'])) { $data['href'] = $this->href(); } $data = array('service' => 'API', 'api' => $version, 'time' => time()) + $this->data; // if an OAuthError is set, return that instead of errors array if (!empty($this->OAuthError)) { $data['error'] = $this->OAuthError; } else { if (count($this->errors)) { ksort($this->errors); $data['errors'] = $this->errors; } } $return = $f3->get('GET.return'); switch ($return) { case 'xml': $this->response->xml($data, $this->params); break; default: case 'json': $this->response->json($data, $this->params); } }
public function _initIndex() { response::xml(); response::sendHeaders(); echo ySitemapIndex::getInstance()->setController($this); }