forked from GNUsocial/gnu-social
Twitter-API: /statuses/replies.format now works (mostly)
darcs-hash:20080717222845-ca946-f2644317a144157aaba7a38d4effb216a9c5f650.gz
This commit is contained in:
parent
8ad7dded2c
commit
c1d109dbb5
@ -84,10 +84,17 @@ class TwitapistatusesAction extends TwitterapiAction {
|
||||
common_start_xml();
|
||||
common_element_start('statuses', array('type' => 'array'));
|
||||
|
||||
if (is_array($notice)) {
|
||||
foreach ($notice as $n) {
|
||||
$twitter_status = $this->twitter_status_array($n);
|
||||
$this->show_twitter_xml_status($twitter_status);
|
||||
}
|
||||
} else {
|
||||
while ($notice->fetch()) {
|
||||
$twitter_status = $this->twitter_status_array($notice);
|
||||
$this->show_twitter_xml_status($twitter_status);
|
||||
}
|
||||
}
|
||||
|
||||
common_element_end('statuses');
|
||||
common_end_xml();
|
||||
@ -106,10 +113,18 @@ class TwitapistatusesAction extends TwitterapiAction {
|
||||
common_element('language', NULL, 'en-us');
|
||||
common_element('ttl', NULL, '40');
|
||||
|
||||
|
||||
if (is_array($notice)) {
|
||||
foreach ($notice as $n) {
|
||||
$entry = $this->twitter_rss_entry_array($n);
|
||||
$this->show_twitter_rss_item($entry);
|
||||
}
|
||||
} else {
|
||||
while ($notice->fetch()) {
|
||||
$entry = $this->twitter_rss_entry_array($notice);
|
||||
$this->show_twitter_rss_item($entry);
|
||||
}
|
||||
}
|
||||
|
||||
common_element_end('channel');
|
||||
$this->end_twitter_rss();
|
||||
@ -126,10 +141,17 @@ class TwitapistatusesAction extends TwitterapiAction {
|
||||
common_element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), NULL);
|
||||
common_element('subtitle', NULL, $subtitle);
|
||||
|
||||
if (is_array($notice)) {
|
||||
foreach ($notice as $n) {
|
||||
$entry = $this->twitter_rss_entry_array($n);
|
||||
$this->show_twitter_atom_entry($entry);
|
||||
}
|
||||
} else {
|
||||
while ($notice->fetch()) {
|
||||
$entry = $this->twitter_rss_entry_array($notice);
|
||||
$this->show_twitter_atom_entry($entry);
|
||||
}
|
||||
}
|
||||
|
||||
$this->end_twitter_atom();
|
||||
}
|
||||
@ -140,10 +162,17 @@ class TwitapistatusesAction extends TwitterapiAction {
|
||||
|
||||
$statuses = array();
|
||||
|
||||
if (is_array($notice)) {
|
||||
foreach ($notice as $n) {
|
||||
$twitter_status = $this->twitter_status_array($n);
|
||||
array_push($statuses, $twitter_status);
|
||||
}
|
||||
} else {
|
||||
while ($notice->fetch()) {
|
||||
$twitter_status = $this->twitter_status_array($notice);
|
||||
array_push($statuses, $twitter_status);
|
||||
}
|
||||
}
|
||||
|
||||
$this->show_twitter_json_statuses($statuses);
|
||||
}
|
||||
@ -437,9 +466,82 @@ class TwitapistatusesAction extends TwitterapiAction {
|
||||
*/
|
||||
function replies($args, $apidata) {
|
||||
parent::handle($args);
|
||||
common_server_error("API method under construction.", $code=501);
|
||||
|
||||
$since = $this->arg('since');
|
||||
|
||||
$count = $this->arg('count');
|
||||
$page = $this->arg('page');
|
||||
|
||||
$user = $apidata['user'];
|
||||
$profile = $user->getProfile();
|
||||
|
||||
$sitename = common_config('site', 'name');
|
||||
$siteserver = common_config('site', 'server');
|
||||
|
||||
$title = sprintf(_("%s / Updates replying to %s"), $sitename, $user->nickname);
|
||||
$id = "tag:$siteserver:replies:".$user->id;
|
||||
$link = common_local_url('replies', array('nickname' => $user->nickname));
|
||||
$subtitle = "gar";
|
||||
$subtitle = sprintf(_("%s updates that reply to updates from %s / %."), $sitename, $user->nickname, $user->nickname);
|
||||
|
||||
if (!$page) {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
if (!$count) {
|
||||
$count = 20;
|
||||
}
|
||||
|
||||
$reply = new Reply();
|
||||
|
||||
$reply->profile_id = $user->id;
|
||||
|
||||
$reply->orderBy('modified DESC');
|
||||
|
||||
$page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||
|
||||
$reply->limit((($page-1)*20), $count);
|
||||
|
||||
$cnt = $reply->find();
|
||||
|
||||
$notices = array();
|
||||
|
||||
if ($cnt) {
|
||||
while ($reply->fetch()) {
|
||||
$notice = new Notice();
|
||||
$notice->id = $reply->notice_id;
|
||||
$result = $notice->find(true);
|
||||
if (!$result) {
|
||||
continue;
|
||||
}
|
||||
$notices[] = clone($notice);
|
||||
}
|
||||
}
|
||||
|
||||
switch($apidata['content-type']) {
|
||||
case 'xml':
|
||||
$this->show_xml_timeline($notices);
|
||||
break;
|
||||
case 'rss':
|
||||
$this->show_rss_timeline($notices, $title, $id, $link, $subtitle);
|
||||
break;
|
||||
case 'atom':
|
||||
$this->show_atom_timeline($notices, $title, $id, $link, $subtitle);
|
||||
break;
|
||||
case 'json':
|
||||
$this->show_json_timeline($notices);
|
||||
break;
|
||||
default:
|
||||
common_user_error("API method not found!", $code = 404);
|
||||
}
|
||||
|
||||
|
||||
exit();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Destroys the status specified by the required ID parameter. The authenticating user must be
|
||||
|
@ -63,7 +63,7 @@ RewriteRule ^api/statuses/friends_timeline(.*)$ index.php?action=api&apiaction=s
|
||||
RewriteRule ^api/statuses/user_timeline(.*)$ index.php?action=api&apiaction=statuses&method=user_timeline$1 [L,QSA]
|
||||
RewriteRule ^api/statuses/show/(.*)$ index.php?action=api&apiaction=statuses&method=show&argument=$1 [L,QSA]
|
||||
RewriteRule ^api/statuses/update(.*)$ index.php?action=api&apiaction=statuses&method=update$1 [L,QSA]
|
||||
RewriteRule ^api/statuses/replies/(.*)$ index.php?action=api&apiaction=statuses&method=replies&argument=$1 [L,QSA]
|
||||
RewriteRule ^api/statuses/replies(.*)$ index.php?action=api&apiaction=statuses&method=replies&argument=$1 [L,QSA]
|
||||
RewriteRule ^api/statuses/destroy/(.*)$ index.php?action=api&apiaction=statuses&method=destroy&argument=$1 [L,QSA]
|
||||
RewriteRule ^api/statuses/friends(.*)$ index.php?action=api&apiaction=statuses&method=friends$1 [L,QSA]
|
||||
RewriteRule ^api/statuses/followers(.*)$ index.php?action=api&apiaction=statuses&method=followers$1 [L,QSA]
|
||||
|
Loading…
Reference in New Issue
Block a user