{
parent::handle($args);
- if (!in_array($this->format, array('xml', 'json'))) {
- $this->clientError(_('API method not found.'), $code = 404);
+ if (!in_array($this->format, array('xml', 'json', 'atom'))) {
+ $this->clientError(_('API method not found.'), 404);
return;
}
function showNotice()
{
if (!empty($this->notice)) {
- if ($this->format == 'xml') {
+ switch ($this->format) {
+ case 'xml':
$this->showSingleXmlStatus($this->notice);
- } elseif ($this->format == 'json') {
+ break;
+ case 'json':
$this->show_single_json_status($this->notice);
+ break;
+ case 'atom':
+ $this->showSingleAtomStatus($this->notice);
+ break;
+ default:
+ throw new Exception(sprintf(_("Unsupported format: %s"), $this->format));
}
} else {
$this->endDocument('xml');
}
+ function showSingleAtomStatus($notice)
+ {
+ header('Content-Type: application/atom+xml; charset=utf-8');
+ print $notice->asAtomEntry(true, true, true, $this->auth_user);
+ }
+
function show_single_json_status($notice)
{
$this->initDocument('json');
$m->connect('api/statuses/show.:format',
array('action' => 'ApiStatusesShow',
- 'format' => '(xml|json)'));
+ 'format' => '(xml|json|atom)'));
$m->connect('api/statuses/show/:id.:format',
array('action' => 'ApiStatusesShow',
'id' => '[0-9]+',
- 'format' => '(xml|json)'));
+ 'format' => '(xml|json|atom)'));
$m->connect('api/statuses/update.:format',
array('action' => 'ApiStatusesUpdate',