4 * XRDS for OpenMicroBlogging
10 * @author Evan Prodromou <evan@status.net>
11 * @author Robin Millette <millette@status.net>
12 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
13 * @link http://status.net/
15 * StatusNet - the distributed open-source microblogging tool
16 * Copyright (C) 2008, 2009, StatusNet, Inc.
18 * This program is free software: you can redistribute it and/or modify
19 * it under the terms of the GNU Affero General Public License as published by
20 * the Free Software Foundation, either version 3 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU Affero General Public License for more details.
28 * You should have received a copy of the GNU Affero General Public License
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 if (!defined('STATUSNET') && !defined('LACONICA')) {
36 require_once INSTALLDIR.'/lib/omb.php';
37 require_once INSTALLDIR.'/extlib/libomb/service_provider.php';
38 require_once INSTALLDIR.'/extlib/libomb/xrds_mapper.php';
39 require_once INSTALLDIR.'/lib/xrdsoutputter.php';
42 * XRDS for OpenMicroBlogging
46 * @author Evan Prodromou <evan@status.net>
47 * @author Robin Millette <millette@status.net>
48 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
49 * @link http://status.net/
51 class XrdsAction extends Action
58 * @return boolean true
65 function prepare($args)
67 parent::prepare($args);
68 $nickname = $this->trimmed('nickname');
69 $this->user = User::staticGet('nickname', $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();