-
Notifications
You must be signed in to change notification settings - Fork 0
/
setsession.php
43 lines (34 loc) · 1.34 KB
/
setsession.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
require_once 'global.php';
require_once 'database.php';
require_once 'modules/register/register_facebook.php';
require_once 'modules/login/facebook_login.php';
global $facebook;
$access_token = $facebook->getAccessToken();
$facebook->setAccessToken($access_token);
//echo $access_token;
//$user_profile = $facebook->api('/me','GET');
try{
$user_profile = $facebook->api('me?fields=id,name,first_name,last_name');
$_SESSION['account_id'] = RegisterFacebook($user_profile['id'], $user_profile['name']);
$_SESSION['facebook_user'] = $user_profile;
if(isset($_SESSION['moderator']))
unset($_SESSION['moderator']);
if(isset($_SESSION['politician']))
unset($_SESSION['politician']);
$_SESSION['normal_user'] = true;
header('Location: '.HOSTNAME);
die();
}
catch(Exception $e){
echo '<html><head><title>Redirecting...</title></head><body>';
echo 'User authenticated. Redirecting... ';
$loginUrl = $facebook->getLoginUrl(array('scope' => 'publish_stream, email', 'redirect_uri' => HOSTNAME.'setsession.php'));
echo '<a id="login" href="' . $loginUrl . '">Click here</a> if you are not redirected within 5 seconds.';
echo '<script type="text/javascript">document.getElementById("login").click()</script>';
echo '</body></html>';
//FacebookLogin();
}
?>