$user = $this->get_user($apidata['api_arg'], $apidata);
if (!$user) {
- $this->client_error('Not Found', 404, $apidata['content-type']);
+ $this->clientError('Not Found', 404, $apidata['content-type']);
return;
}
$profile = $user->getProfile();
if (!$profile) {
- common_server_error(_('User has no profile.'));
+ $this->serverError(_('User has no profile.'));
return;
}
$notice = $user->favoriteNotices((($page-1)*20), $count);
if (!$notice) {
- common_server_error(_('Could not retrieve favorite notices.'));
+ $this->serverError(_('Could not retrieve favorite notices.'));
return;
}
$sitename = common_config('site', 'name');
- $siteserver = common_config('site', 'server');
-
$title = sprintf(_('%s / Favorites from %s'), $sitename, $user->nickname);
- $id = "tag:$siteserver:favorites:".$user->id;
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:Favorites:".$user->id;
$link = common_local_url('favorites', array('nickname' => $user->nickname));
$subtitle = sprintf(_('%s updates favorited by %s / %s.'), $sitename, $profile->getBestName(), $user->nickname);
$this->show_rss_timeline($notice, $title, $link, $subtitle);
break;
case 'atom':
- $this->show_atom_timeline($notice, $title, $id, $link, $subtitle);
+ if (isset($apidata['api_arg'])) {
+ $selfuri = $selfuri = common_root_url() .
+ 'api/favorites/' . $apidata['api_arg'] . '.atom';
+ } else {
+ $selfuri = $selfuri = common_root_url() .
+ 'api/favorites.atom';
+ }
+ $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, null, $selfuri);
break;
case 'json':
$this->show_json_timeline($notice);
break;
default:
- common_user_error(_('API method not found!'), $code = 404);
+ $this->clientError(_('API method not found!'), $code = 404);
}
}
// Check for RESTfulness
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
// XXX: Twitter just prints the err msg, no XML / JSON.
- $this->client_error(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
+ $this->clientError(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
return;
}
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
- common_user_error(_('API method not found!'), $code = 404);
+ $this->clientError(_('API method not found!'), $code = 404);
return;
}
$notice = Notice::staticGet($notice_id);
if (!$notice) {
- $this->client_error(_('No status found with that ID.'), 404, $apidata['content-type']);
+ $this->clientError(_('No status found with that ID.'), 404, $apidata['content-type']);
return;
}
// XXX: Twitter lets you fave things repeatedly via api.
if ($user->hasFave($notice)) {
- $this->client_error(_('This notice is already a favorite!'), 403, $apidata['content-type']);
+ $this->clientError(_('This notice is already a favorite!'), 403, $apidata['content-type']);
return;
}
$fave = Fave::addNew($user, $notice);
if (!$fave) {
- common_server_error(_('Could not create favorite.'));
+ $this->serverError(_('Could not create favorite.'));
return;
}
function destroy($args, $apidata)
{
parent::handle($args);
- common_server_error(_('API method under construction.'), $code=501);
+ $this->serverError(_('API method under construction.'), $code=501);
}
// XXX: these two funcs swiped from faves. Maybe put in util.php, or some common base class?