]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/twitapilaconica.php
add some breaks so that switch statement works
[quix0rs-gnu-social.git] / actions / twitapilaconica.php
1 <?php
2 /**
3  * Laconica, the distributed open-source microblogging tool
4  *
5  * Laconica-only extensions to the Twitter-like API
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   Laconica
24  * @author    Evan Prodromou <evan@controlyourself.ca>
25  * @copyright 2008 Control Yourself, Inc.
26  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27  * @link      http://laconi.ca/
28  */
29
30 if (!defined('LACONICA')) {
31     exit(1);
32 }
33
34 require_once INSTALLDIR.'/lib/twitterapi.php';
35
36 /**
37  * Laconica-specific API methods
38  *
39  * This class handles all /laconica/ API methods.
40  *
41  * @category  Twitter
42  * @package   Laconica
43  * @author    Evan Prodromou <evan@controlyourself.ca>
44  * @copyright 2008 Control Yourself, Inc.
45  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
46  * @link      http://laconi.ca/
47  */
48
49 class TwitapilaconicaAction extends TwitterapiAction
50 {
51     /**
52      * A version stamp for the API
53      *
54      * Returns a version number for this version of Laconica, which
55      * should make things a bit easier for upgrades.
56      * URL: http://identi.ca/api/laconica/version.(xml|json)
57      * Formats: xml, json
58      *
59      * @param array $args    Web arguments
60      * @param array $apidata Twitter API data
61      *
62      * @return void
63      *
64      * @see ApiAction::process_command()
65      */
66
67     function version($args, $apidata)
68     {
69         parent::handle($args);
70         switch ($apidata['content-type']) {
71          case 'xml':
72             $this->init_document('xml');
73             common_element('version', null, LACONICA_VERSION);
74             $this->end_document('xml');
75             break;
76          case 'json':
77             $this->init_document('json');
78             print '"'.LACONICA_VERSION.'"';
79             $this->end_document('json');
80             break;
81          default:
82             $this->client_error(_('API method not found!'), $code=404);
83         }
84     }
85
86     /**
87      * Dump of configuration variables
88      *
89      * Gives a full dump of configuration variables for this instance
90      * of Laconica, minus variables that may be security-sensitive (like
91      * passwords).
92      *
93      * @param array $args    Web arguments
94      * @param array $apidata Twitter API data
95      *
96      * @return void
97      *
98      * @see ApiAction::process_command()
99      */
100
101     function config($args, $apidata)
102     {
103         parent::handle($args);
104         common_server_error(_('API method under construction.'), 501);
105     }
106
107     /**
108      * WADL description of the API
109      *
110      * Gives a WADL description of the API provided by this version of the
111      * software.
112      *
113      * @param array $args    Web arguments
114      * @param array $apidata Twitter API data
115      *
116      * @return void
117      *
118      * @see ApiAction::process_command()
119      */
120
121     function wadl($args, $apidata)
122     {
123         parent::handle($args);
124         common_server_error(_('API method under construction.'), 501);
125     }
126 }