]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/twitapitags.php
change Laconica and Control Yourself to StatusNet in PHP files
[quix0rs-gnu-social.git] / actions / twitapitags.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * StatusNet extensions to the Twitter-like API for groups
6  *
7  * PHP version 5
8  *
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.
13  *
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.
18  *
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/>.
21  *
22  * @category  Twitter
23  * @package   StatusNet
24  * @author    Craig Andrews
25  * @author    Zach Copley <zach@controlyourself.ca>
26  * @copyright 2009 StatusNet, 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/
29  */
30
31 if (!defined('LACONICA')) {
32     exit(1);
33 }
34
35 require_once INSTALLDIR.'/lib/twitterapi.php';
36
37 /**
38  * Group-specific API methods
39  *
40  * This class handles StatusNet group API methods.
41  *
42  * @category  Twitter
43  * @package   StatusNet
44  * @author    Craig Andrews
45  * @author    Zach Copley <zach@controlyourself.ca>
46  * @copyright 2009 StatusNet, 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/
49  */
50
51  class TwitapitagsAction extends TwitterapiAction
52  {
53
54      function timeline($args, $apidata)
55      {
56          parent::handle($args);
57
58          common_debug("in tags api action");
59
60          $this->auth_user = $apidata['user'];
61          $tag = $apidata['api_arg'];
62
63          if (empty($tag)) {
64              $this->clientError('Not Found', 404, $apidata['content-type']);
65              return;
66          }
67
68          $sitename   = common_config('site', 'name');
69          $title      = sprintf(_("Notices tagged with %s"), $tag);
70          $taguribase = common_config('integration', 'taguri');
71          $id         = "tag:$taguribase:TagTimeline:".$tag;
72          $link       = common_local_url('tag',
73              array('tag' => $tag));
74          $subtitle   = sprintf(_('Updates tagged with %1$s on %2$s!'),
75              $tag, $sitename);
76
77          $page     = (int)$this->arg('page', 1);
78          $count    = (int)$this->arg('count', 20);
79          $max_id   = (int)$this->arg('max_id', 0);
80          $since_id = (int)$this->arg('since_id', 0);
81          $since    = $this->arg('since');
82
83          # XXX: support max_id, since_id, and since arguments
84          $notice = Notice_tag::getStream($tag, ($page-1)*$count, $count + 1);
85
86          switch($apidata['content-type']) {
87           case 'xml':
88              $this->show_xml_timeline($notice);
89              break;
90           case 'rss':
91              $this->show_rss_timeline($notice, $title, $link, $subtitle);
92              break;
93           case 'atom':
94              if (isset($apidata['api_arg'])) {
95                  $selfuri = common_root_url() .
96                      'api/laconica/tags/timeline/' .
97                          $apidata['api_arg'] . '.atom';
98              } else {
99                  $selfuri = common_root_url() .
100                   'api/laconica/tags/timeline.atom';
101              }
102              $this->show_atom_timeline($notice, $title, $id, $link,
103                  $subtitle, null, $selfuri);
104              break;
105           case 'json':
106              $this->show_json_timeline($notice);
107              break;
108           default:
109              $this->clientError(_('API method not found!'), $code = 404);
110          }
111      }
112
113 }