-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
104 lines (80 loc) · 2.86 KB
/
index.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
session_start();
require('facebook-php-sdk-v4-4.0-dev/autoload.php');
use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;
const APPID = "1418421185132612";
const APPSECRET = "aaf24809cc74fe8df53b69b6cc006108";
FacebookSession::setDefaultApplication(APPID, APPSECRET);
$helper = new FacebookRedirectLoginHelper('https://oosbe.herokuapp.com/');
if(isset($_SESSION) && isset($_SESSION['fb_token'])){
$session = new FacebookSession($_SESSION['fb_token']);
} else {
$session = $helper->getSessionFromRedirect();
}
$loginUrl = $helper->getLoginUrl();
if($session){
try{
$user_profile = (new FacebookRequest($session, 'GET', '/me'))->execute()->getGraphObject(GraphUser::className());
var_dump($user_profile);
$fb = $user_profile->getName();
$idfb = $user_profile->getId();
$link = $user_profile->getLink();
$locationdude = "http://sd7.danem.fr/oosbe/try.php?nom_fb=".$fb."&id_fb=".$idfb;
echo "<br /><br /><br />";
$user_id = $session->getUserId();
echo "<br /><br /><br />";
var_dump($user_id);
?>
<!--<script>
function newDoc() {
window.location.assign("<?php echo $locationdude;?>")
}
</script>-->
<input type="button" value="Mettre à jour mon profil" onclick="newDoc()">
<?php
}
catch(FacebookRequestException $e){
echo "Exception occured code : ". $e->getCode();
echo " with message ". $e->getMessage();
}
} else {
echo " <br /> <br /><center> Veuillez vous <a href='".$loginUrl."'> connecter</a> </center> ";
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Welcome to Facebook App</title>
<meta name="description" content="Description de ma page" >
<style>
a{
font-size:20px;
}
</style>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<?php echo APPID; ?>',
xfbml : true,
version : 'v2.3'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/fr_FR/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
</head>
<body>
</body>
</html>