if (!$other) {
$this->client_error(_('No such user'));
+ exit();
return;
}
if ($user->isSubscribed($other)) {
$this->client_error(_('Already subscribed.'));
+ exit();
return;
}
if (!$result) {
$this->server_error(_('Could not subscribe'));
+ exit();
return;
}
mail_subscribe_notify($other, $user);
- common_start_xml();
+ $type = $apidata['content-type'];
+ $this->init_document($type);
$this->show_profile($other);
- common_end_xml();
+ $this->end_document($type);
exit();
}
$sub->delete();
}
- common_start_xml();
+ $type = $apidata['content-type'];
+ $this->init_document($type);
$this->show_profile($other);
- common_end_xml();
+ $this->end_document($type);
exit();
}
return NULL;
}
+
+ function init_document($type='xml') {
+ switch ($type) {
+ case 'xml':
+ header('Content-Type: application/xml; charset=utf-8');
+ common_start_xml();
+ break;
+ case 'json':
+ header('Content-Type: application/json; charset=utf-8');
+ break;
+ case 'rss':
+ header("Content-Type: application/rss+xml; charset=utf-8");
+ $this->init_twitter_rss();
+ break;
+ case 'atom':
+ header('Content-Type: application/atom+xml; charset=utf-8');
+ $this->init_twitter_atom();
+ break;
+ default:
+ $this->client_error(_('Unsupported type'));
+ break;
+ }
+ }
+
+ function end_document($type='xml') {
+ switch ($type) {
+ case 'xml':
+ common_end_xml();
+ break;
+ case 'json':
+ break;
+ case 'rss':
+ $this->end_twitter_rss();
+ break;
+ case 'atom':
+ $this->end_twitter_rss();
+ break;
+ default:
+ $this->client_error(_('Unsupported type'));
+ break;
+ }
+ }
function init_twitter_rss() {
common_start_xml();