3 * Laconica, the distributed open-source microblogging tool
5 * Laconica-only extensions to the Twitter-like API
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 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/
30 if (!defined('LACONICA')) {
34 require_once INSTALLDIR.'/lib/twitterapi.php';
37 * Laconica-specific API methods
39 * This class handles all /laconica/ API methods.
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/
49 class TwitapilaconicaAction extends TwitterapiAction
52 * A version stamp for the API
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)
59 * @param array $args Web arguments
60 * @param array $apidata Twitter API data
64 * @see ApiAction::process_command()
67 function version($args, $apidata)
69 parent::handle($args);
70 switch ($apidata['content-type']) {
72 $this->init_document('xml');
73 $this->element('version', null, LACONICA_VERSION);
74 $this->end_document('xml');
77 $this->init_document('json');
78 print '"'.LACONICA_VERSION.'"';
79 $this->end_document('json');
82 $this->clientError(_('API method not found!'), $code=404);
87 * Dump of configuration variables
89 * Gives a full dump of configuration variables for this instance
90 * of Laconica, minus variables that may be security-sensitive (like
92 * URL: http://identi.ca/api/laconica/config.(xml|json)
95 * @param array $args Web arguments
96 * @param array $apidata Twitter API data
100 * @see ApiAction::process_command()
103 function config($args, $apidata)
105 static $keys = array('site' => array('name', 'server', 'theme', 'path', 'fancy', 'language',
106 'email', 'broughtby', 'broughtbyurl', 'closed',
107 'inviteonly', 'private'),
108 'license' => array('url', 'title', 'image'),
109 'nickname' => array('featured'),
110 'throttle' => array('enabled', 'count', 'timespan'),
111 'xmpp' => array('enabled', 'server', 'user'));
113 parent::handle($args);
115 switch ($apidata['content-type']) {
117 $this->init_document('xml');
118 $this->elementStart('config');
119 // XXX: check that all sections and settings are legal XML elements
120 foreach ($keys as $section => $settings) {
121 $this->elementStart($section);
122 foreach ($settings as $setting) {
123 $value = common_config($section, $setting);
124 if (is_array($value)) {
125 $value = implode(',', $value);
126 } else if ($value === false) {
128 } else if ($value === true) {
131 $this->element($setting, null, $value);
133 $this->elementEnd($section);
135 $this->elementEnd('config');
136 $this->end_document('xml');
140 foreach ($keys as $section => $settings) {
141 $result[$section] = array();
142 foreach ($settings as $setting) {
143 $result[$section][$setting] = common_config($section, $setting);
146 $this->init_document('json');
147 $this->show_json_objects($result);
148 $this->end_document('json');
151 $this->clientError(_('API method not found!'), $code=404);
156 * WADL description of the API
158 * Gives a WADL description of the API provided by this version of the
161 * @param array $args Web arguments
162 * @param array $apidata Twitter API data
166 * @see ApiAction::process_command()
169 function wadl($args, $apidata)
171 parent::handle($args);
172 $this->serverError(_('API method under construction.'), 501);