3 * StatusNet, the distributed open-source microblogging tool
5 * Show the friends timeline
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Zach Copley <zach@status.net>
25 * @copyright 2009 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('STATUSNET')) {
34 require_once INSTALLDIR.'/lib/twitterapi.php';
36 class ApifriendstimelineAction extends TwitterapiAction
40 * Take arguments for running
42 * @param array $args $_REQUEST args
44 * @return boolean success flag
48 function prepare($args)
50 parent::prepare($args);
55 function handle($args) {
57 parent::handle($args);
58 common_debug(var_export($args, true));
60 if ($this->requiresAuth()) {
61 if ($this->showBasicAuthHeader()) {
62 $this->showTimeline();
65 $this->showTimeline();
69 function showTimeline()
71 common_debug('Auth user = ' . var_export($this->auth_user, true));
73 $user = $this->getTargetUser($this->arg('id'));
76 $this->clientError(_('No such user!'), 404, $this->arg('format'));
80 $profile = $user->getProfile();
81 $sitename = common_config('site', 'name');
82 $title = sprintf(_("%s and friends"), $user->nickname);
83 $taguribase = common_config('integration', 'taguri');
84 $id = "tag:$taguribase:FriendsTimeline:" . $user->id;
85 $link = common_local_url('all',
86 array('nickname' => $user->nickname));
87 $subtitle = sprintf(_('Updates from %1$s and friends on %2$s!'),
88 $user->nickname, $sitename);
90 $page = (int)$this->arg('page', 1);
91 $count = (int)$this->arg('count', 20);
92 $max_id = (int)$this->arg('max_id', 0);
93 $since_id = (int)$this->arg('since_id', 0);
94 $since = $this->arg('since');
96 if (!empty($this->auth_user) && $this->auth_user->id == $user->id) {
97 $notice = $user->noticeInbox(($page-1)*$count,
98 $count, $since_id, $max_id, $since);
100 $notice = $user->noticesWithFriends(($page-1)*$count,
101 $count, $since_id, $max_id, $since);
104 switch($this->arg('format')) {
106 $this->show_xml_timeline($notice);
109 $this->show_rss_timeline($notice, $title, $link, $subtitle);
113 $target_id = $this->arg('id');
115 if (isset($target_id)) {
116 $selfuri = common_root_url() .
117 'api/statuses/friends_timeline/' .
118 $target_id . '.atom';
120 $selfuri = common_root_url() .
121 'api/statuses/friends_timeline.atom';
123 $this->show_atom_timeline($notice, $title, $id, $link,
124 $subtitle, null, $selfuri);
127 $this->show_json_timeline($notice);
130 $this->clientError(_('API method not found!'), $code = 404);
135 function requiresAuth()
141 * Is this page read-only?
143 * @return boolean true
146 function isReadOnly($args)
152 * When was this page last modified?
156 function lastModified()