3 * Laconica, the distributed open-source microblogging tool
5 * Laconica extensions to the Twitter-like API for groups
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 Craig Andrews
25 * @author Zach Copley <zach@controlyourself.ca>
26 * @copyright 2009 Control Yourself, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28 * @link http://laconi.ca/
31 if (!defined('LACONICA')) {
35 require_once INSTALLDIR.'/lib/twitterapi.php';
38 * Group-specific API methods
40 * This class handles Laconica group API methods.
44 * @author Craig Andrews
45 * @author Zach Copley <zach@controlyourself.ca>
46 * @copyright 2009 Control Yourself, Inc.
47 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
48 * @link http://laconi.ca/
51 class TwitapigroupsAction extends TwitterapiAction
54 function show($args, $apidata)
56 parent::handle($args);
58 common_debug("in groups api action");
60 $this->auth_user = $apidata['user'];
61 $group = $this->get_group($apidata['api_arg'], $apidata);
64 $this->clientError('Not Found', 404, $apidata['content-type']);
68 switch($apidata['content-type']) {
70 $this->show_single_xml_group($group);
73 $this->show_single_json_group($group);
76 $this->clientError(_('API method not found!'), $code = 404);
80 function timeline($args, $apidata)
82 parent::handle($args);
84 common_debug("in groups api action");
86 $this->auth_user = $apidata['user'];
87 $group = $this->get_group($apidata['api_arg'], $apidata);
90 $this->clientError('Not Found', 404, $apidata['content-type']);
94 $sitename = common_config('site', 'name');
95 $title = sprintf(_("%s timeline"), $group->nickname);
96 $taguribase = common_config('integration', 'taguri');
97 $id = "tag:$taguribase:GroupTimeline:".$group->id;
98 $link = common_local_url('showgroup',
99 array('nickname' => $group->nickname));
100 $subtitle = sprintf(_('Updates from %1$s on %2$s!'),
101 $group->nickname, $sitename);
103 $page = (int)$this->arg('page', 1);
104 $count = (int)$this->arg('count', 20);
105 $max_id = (int)$this->arg('max_id', 0);
106 $since_id = (int)$this->arg('since_id', 0);
107 $since = $this->arg('since');
109 $notice = $group->getNotices(($page-1)*$count,
110 $count, $since_id, $max_id, $since);
112 switch($apidata['content-type']) {
114 $this->show_xml_timeline($notice);
117 $this->show_rss_timeline($notice, $title, $link, $subtitle);
120 if (isset($apidata['api_arg'])) {
121 $selfuri = common_root_url() .
122 'api/laconica/groups/timeline/' .
123 $apidata['api_arg'] . '.atom';
125 $selfuri = common_root_url() .
126 'api/laconica/groups/timeline.atom';
128 $this->show_atom_timeline($notice, $title, $id, $link,
129 $subtitle, null, $selfuri);
132 $this->show_json_timeline($notice);
135 $this->clientError(_('API method not found!'), $code = 404);