]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/requesttoken.php
Merge branch '0.8.x' of git://gitorious.org/~brion/statusnet/brion-fixes into 0.8.x
[quix0rs-gnu-social.git] / actions / requesttoken.php
1 <?php
2
3 /**
4  * Request token action class.
5  *
6  * PHP version 5
7  *
8  * @category Action
9  * @package  StatusNet
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/
14  *
15  * StatusNet - the distributed open-source microblogging tool
16  * Copyright (C) 2008, 2009, StatusNet, Inc.
17  *
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.
22  *
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.
27  *
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/>.
30  */
31
32 if (!defined('STATUSNET') && !defined('LACONICA')) {
33     exit(1);
34 }
35
36 require_once INSTALLDIR.'/lib/omb.php';
37
38 /**
39  * Request token action class.
40  *
41  * @category Action
42  * @package  StatusNet
43  * @author   Evan Prodromou <evan@status.net>
44  * @author   Robin Millette <millette@status.net>
45  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
46  * @link     http://status.net/
47  */
48 class RequesttokenAction extends Action
49 {
50      /**
51      * Is read only?
52      * 
53      * @return boolean false
54      */
55     function isReadOnly($args)
56     {
57         return false;
58     }
59     
60     /**
61      * Class handler.
62      * 
63      * @param array $args array of arguments
64      *
65      * @return void
66      */
67     function handle($args)
68     {
69         parent::handle($args);
70         try {
71             common_remove_magic_from_request();
72             $req    = OAuthRequest::from_request('POST', common_local_url('requesttoken'));
73             $server = omb_oauth_server();
74             $token  = $server->fetch_request_token($req);
75             print $token.'&omb_version='.OMB_VERSION_01;
76         } catch (OAuthException $e) {
77             $this->serverError($e->getMessage());
78         }
79     }
80 }
81