3 * Laconica - a distributed open-source microblogging tool
4 * Copyright (C) 2008, Controlez-Vous, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('LACONICA')) { exit(1); }
22 define('OPENMICROBLOGGING01', 'http://openmicroblogging.org/protocol/0.1');
24 class XrdsAction extends Action {
26 function handle($args) {
27 parent::handle($args);
28 $nickname = $this->trimmed('nickname');
29 $user = User::staticGet('nickname', $nickname);
31 common_user_error(_t('No such user.'));
34 $this->show_xrds($user);
37 function show_xrds($user) {
39 header('Content-Type: application/rdf+xml');
42 common_element_start('xrds:XRDS', array('xmlns:xrds' => 'xri://$xrds',
43 'xmlns' => 'xri://$xrd*($v*2.0)'));
44 common_element_start('XRD');
46 $this->show_service(OPENMICROBLOGGING01.'/identifier',
49 # XXX: decide whether to include user's ID/nickname in postNotice URL
51 foreach (array('requestToken', 'userAuthorization',
52 'accessToken', 'postNotice',
53 'updateProfile') as $type) {
54 $this->show_service(OPENMICROBLOGGING01.'/'.$type,
55 common_local_url(strtolower($type)));
58 common_element_end('XRD');
59 common_element_end('xrds:XRDS');
63 function show_service($type, $uri) {
64 common_element_start('Service');
65 common_element('Type', $type);
66 common_element('URI', $uri);
67 common_element_end('Service');