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 require_once(INSTALLDIR.'/lib/omb.php');
24 class XrdsAction extends Action
32 function handle($args)
34 parent::handle($args);
35 $nickname = $this->trimmed('nickname');
36 $user = User::staticGet('nickname', $nickname);
38 $this->clientError(_('No such user.'));
41 $this->show_xrds($user);
44 function show_xrds($user)
47 header('Content-Type: application/xrds+xml');
50 $this->elementStart('XRDS', array('xmlns' => 'xri://$xrds'));
52 $this->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
54 'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
57 $this->element('Type', null, 'xri://$xrds*simple');
59 $this->show_service(OAUTH_ENDPOINT_REQUEST,
60 common_local_url('requesttoken'),
61 array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY),
62 array(OAUTH_HMAC_SHA1),
65 $this->show_service(OAUTH_ENDPOINT_AUTHORIZE,
66 common_local_url('userauthorization'),
67 array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY),
68 array(OAUTH_HMAC_SHA1));
70 $this->show_service(OAUTH_ENDPOINT_ACCESS,
71 common_local_url('accesstoken'),
72 array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY),
73 array(OAUTH_HMAC_SHA1));
75 $this->show_service(OAUTH_ENDPOINT_RESOURCE,
77 array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY),
78 array(OAUTH_HMAC_SHA1));
80 $this->elementEnd('XRD');
82 # XXX: decide whether to include user's ID/nickname in postNotice URL
84 $this->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
86 'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
89 $this->element('Type', null, 'xri://$xrds*simple');
91 $this->show_service(OMB_ENDPOINT_POSTNOTICE,
92 common_local_url('postnotice'));
94 $this->show_service(OMB_ENDPOINT_UPDATEPROFILE,
95 common_local_url('updateprofile'));
97 $this->elementEnd('XRD');
99 $this->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
100 'version' => '2.0'));
102 $this->element('Type', null, 'xri://$xrds*simple');
104 $this->show_service(OAUTH_DISCOVERY,
106 $this->show_service(OMB_NAMESPACE,
109 $this->elementEnd('XRD');
111 $this->elementEnd('XRDS');
115 function show_service($type, $uri, $params=null, $sigs=null, $localId=null)
117 $this->elementStart('Service');
119 $this->element('URI', null, $uri);
121 $this->element('Type', null, $type);
123 foreach ($params as $param) {
124 $this->element('Type', null, $param);
128 foreach ($sigs as $sig) {
129 $this->element('Type', null, $sig);
133 $this->element('LocalID', null, $localId);
135 $this->elementEnd('Service');