881cb4934e3b2157637c796883ddd824bfd62379
[atutor.git] / docs / mods / _standard / social / lib / OAuth / approve_authorization.php
1 <?php
2 /***********************************************************************/
3 /* ATutor                                                                                                                          */
4 /***********************************************************************/
5 /* Copyright (c) 2002-2010                                             */
6 /* Inclusive Design Institute                                          */
7 /* http://atutor.ca                                                                                                        */
8 /*                                                                                                                                         */
9 /* This program is free software. You can redistribute it and/or           */
10 /* modify it under the terms of the GNU General Public License             */
11 /* as published by the Free Software Foundation.                                           */
12 /***********************************************************************/
13 // $Id$
14
15 require_once('OAuth.php');
16 require_once('../Shindig/ATutorOAuthDataStore.php');
17
18 session_name('ATutorID');
19 session_start();
20
21 $oauthDataStore = new ATutorOAuthDataStore();
22
23 $oauth_token = $_REQUEST['oauth_token'];
24 $oauth_callback = $_REQUEST['oauth_callback'];
25 try {   
26         $oauthDataStore->authorize_request_token($oauth_token);
27
28         // if callback was provided, append token and return to the callback
29         if ($oauth_callback) {
30           $oauth_callback .= (strpos($oauth_callback, '?') === false ? '?' : '&');
31           $oauth_callback .= 'oauth_token=' . urlencode($oauth_token);
32           header('Location:' . $oauth_callback);
33         } else {
34           echo "Your application is now authorized.";
35         }
36 } catch (OAuthException $e) {
37   echo $e->getMessage();
38 } catch (Exception $e) {
39   echo $e->getMessage();
40 }
41 ?>