-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfbconfig.php
More file actions
52 lines (37 loc) · 1.26 KB
/
Copy pathfbconfig.php
File metadata and controls
52 lines (37 loc) · 1.26 KB
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
44
45
46
47
48
49
50
51
52
<?php
require 'facebook.php'; // Include facebook SDK file
require 'functions.php'; // Include functions
if($session) {
try {
$user_profile = (new FacebookRequest(
$session, 'GET', '/me'
))->execute()->getGraphObject(GraphUser::className());
echo "Name: " . $user_profile->getName();
} catch(FacebookRequestException $e) {
echo "Exception occured, code: " . $e->getCode();
echo " with message: " . $e->getMessage();
}
}
if ($user_profile) {
try {
$fbid = $user_profile['id']; // To Get Facebook ID
$fbuname = $user_profile['username']; // To Get Facebook Username
$fbfullname = $user_profile['name']; // To Get Facebook full name
$femail = $user_profile['email']; // To Get Facebook email ID
/* ---- Session Variables -----*/
$_SESSION['FBID'] = $fbid;
$_SESSION['USERNAME'] = $fbuname;
$_SESSION['FULLNAME'] = $fbfullname;
$_SESSION['EMAIL'] = $femail;
// checkuser($fbid,$fbuname,$fbfullname,$femail); // To update local DB
} catch (FacebookApiException $e) {
error_log($e);
$user_profile = null;
}
}
if ($user_profile) {
header("Location: findex.html");
} else {
header("Location: findex.html");
}
?>