]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/xrds.php
use notice URIs in RSS feeds
[quix0rs-gnu-social.git] / actions / xrds.php
1 <?php
2 /*
3  * Laconica - a distributed open-source microblogging tool
4  * Copyright (C) 2008, Controlez-Vous, Inc.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 if (!defined('LACONICA')) { exit(1); }
21
22 define('OPENMICROBLOGGING01', 'http://openmicroblogging.org/protocol/0.1');
23
24 class XrdsAction extends Action {
25
26         function handle($args) {
27                 parent::handle($args);
28                 $nickname = $this->trimmed('nickname');
29                 $user = User::staticGet('nickname', $nickname);
30                 if (!$user) {
31                         common_user_error(_t('No such user.'));
32                         return;
33                 }
34                 $this->show_xrds($user);
35         }
36
37         function show_xrds($user) {
38                 
39                 header('Content-Type: application/rdf+xml');
40
41                 common_start_xml();
42                 common_element_start('xrds:XRDS', array('xmlns:xrds' => 'xri://$xrds',
43                                                                                                 'xmlns' => 'xri://$xrd*($v*2.0)'));
44                 common_element_start('XRD');
45
46                 $this->show_service(OPENMICROBLOGGING01.'/identifier',
47                                                         $user->uri);
48
49                 # XXX: decide whether to include user's ID/nickname in postNotice URL
50                 
51                 foreach (array('requestToken', 'userAuthorization',
52                                            'accessToken', 'postNotice',
53                                            'updateProfile') as $type) {
54                         $this->show_service(OPENMICROBLOGGING01.'/'.$type,
55                                                                 common_local_url(strtolower($type)));
56                 }
57                 
58                 common_element_end('XRD');
59                 common_element_end('xrds:XRDS');
60                 common_end_xml();
61         }
62         
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');
68         }
69 }