3 * XRDS for OpenMicroBlogging
9 * @author Evan Prodromou <evan@status.net>
10 * @author Robin Millette <millette@status.net>
11 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
12 * @link http://status.net/
14 * StatusNet - the distributed open-source microblogging tool
15 * Copyright (C) 2008, 2009, StatusNet, Inc.
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU Affero General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU Affero General Public License for more details.
27 * You should have received a copy of the GNU Affero General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 if (!defined('STATUSNET') && !defined('LACONICA')) {
35 require_once INSTALLDIR.'/lib/omb.php';
36 require_once INSTALLDIR.'/extlib/libomb/service_provider.php';
37 require_once INSTALLDIR.'/extlib/libomb/xrds_mapper.php';
38 require_once INSTALLDIR.'/lib/xrdsoutputter.php';
41 * XRDS for OpenMicroBlogging
45 * @author Evan Prodromou <evan@status.net>
46 * @author Robin Millette <millette@status.net>
47 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
48 * @link http://status.net/
50 class XrdsAction extends Action
57 * @return boolean true
64 function prepare($args)
66 parent::prepare($args);
67 $nickname = $this->trimmed('nickname');
68 $this->user = User::staticGet('nickname', $nickname);
70 // TRANS: Client error displayed providing a non-existing nickname.
71 $this->clientError(_('No such user.'));
80 * @param array $args query arguments
84 function handle($args)
86 parent::handle($args);
87 $xrdsOutputter = new XRDSOutputter();
88 $xrdsOutputter->startXRDS();
90 Event::handle('StartUserXRDS', array($this,&$xrdsOutputter));
93 $xrdsOutputter->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
95 'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
97 $xrdsOutputter->element('Type', null, 'xri://$xrds*simple');
98 $xrdsOutputter->showXrdsService(OAUTH_ENDPOINT_REQUEST,
99 common_local_url('requesttoken'),
100 array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY, OAUTH_HMAC_SHA1),
103 $xrdsOutputter->showXrdsService( OAUTH_ENDPOINT_AUTHORIZE,
104 common_local_url('userauthorization'),
105 array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY, OAUTH_HMAC_SHA1));
106 $xrdsOutputter->showXrdsService(OAUTH_ENDPOINT_ACCESS,
107 common_local_url('accesstoken'),
108 array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY, OAUTH_HMAC_SHA1));
109 $xrdsOutputter->showXrdsService(OAUTH_ENDPOINT_RESOURCE,
111 array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY, OAUTH_HMAC_SHA1));
112 $xrdsOutputter->elementEnd('XRD');
115 $xrdsOutputter->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
117 'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
118 'version' => '2.0'));
119 $xrdsOutputter->element('Type', null, 'xri://$xrds*simple');
120 $xrdsOutputter->showXrdsService(OMB_ENDPOINT_POSTNOTICE,
121 common_local_url('postnotice'));
122 $xrdsOutputter->showXrdsService(OMB_ENDPOINT_UPDATEPROFILE,
123 common_local_url('updateprofile'));
124 $xrdsOutputter->elementEnd('XRD');
126 Event::handle('EndUserXRDS', array($this,&$xrdsOutputter));
129 $xrdsOutputter->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
130 'version' => '2.0'));
131 $xrdsOutputter->showXrdsService(OAUTH_DISCOVERY,
133 $xrdsOutputter->showXrdsService(OMB_VERSION,
135 $xrdsOutputter->elementEnd('XRD');
137 $xrdsOutputter->endXRDS();