-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
128 lines (99 loc) · 3.64 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<html>
<head>
<title>Facebook App</title>
<style type="text/css">
body {
background-image: url("wallpaper.jpeg");
background-size: 1600px 800px;
background-repeat: no-repeat;
}
.warning{font-family:Arial, Helvetica, sans-serif;color:#FFF; top:0px;position:relative;left:400px;font-size:40px;}
.you { position: relative; top: -200px; left: 300px; }
.cross { position: absolute; top: -200px; left: 270px; }
.letter{position:absolute; top:-200px; left:800px;}
.content{font-family: Papyrus,fantasy;top:-300px;left:820px;position:relative;font-size:20px; }
.link{
background-image: url("click.png");
background-size: 400px 50px;
width: 400px;
height:50px;
display:block;
background-repeat: no-repeat;
position:relative;
}
.skull{
width: 250px;
height:300px;
left:700px;
position:relative;
}
</style>
<script>var hidden = false;
var count = 1;
setInterval(function(){ // This function is here for the blink effect of the button
document.getElementById("link").style.visibility= hidden ? "visible" : "hidden"; // setInterval will execute this infinite time
// within interval of 300 seconds
hidden = !hidden;
},300);
</script>
</head>
<body>
<h1 class="warning" id="warning"><b>Who will be your Best Friend in next life?</b></h1>
<img src="man1.png" class="man"/>
<img src="skull.png" class="skull"/>
</body>
</html>
<?php
// new
session_start();
require_once __DIR__ . '/Facebook/autoload.php';
$fb = new Facebook\Facebook([
'app_id' => '802321426608667',
'app_secret' => 'c80b2429187e1caf01f36591d18abc56',
'default_graph_version' => 'v2.9',
]);
$helper = $fb->getRedirectLoginHelper();
//$permissions = ['email']; // optional
//$permissions = ['friendlist'];
$permissions = array("email","user_friends");
try {
if (isset($_SESSION['facebook_access_token'])) {
$accessToken = $_SESSION['facebook_access_token'];
} else {
$accessToken = $helper->getAccessToken();
}
} catch(Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
if (isset($accessToken)) {
if (isset($_SESSION['facebook_access_token'])) {
$fb->setDefaultAccessToken($_SESSION['facebook_access_token']);
header('Location: http://localhost/facebook/i.php');
} else {
// getting short-lived access token
$_SESSION['facebook_access_token'] = (string) $accessToken;
// OAuth 2.0 client handler
$oAuth2Client = $fb->getOAuth2Client();
// Exchanges a short-lived access token for a long-lived one
$longLivedAccessToken = $oAuth2Client->getLongLivedAccessToken($_SESSION['facebook_access_token']);
$_SESSION['facebook_access_token'] = (string) $longLivedAccessToken;
// setting default access token to be used in script
$fb->setDefaultAccessToken($_SESSION['facebook_access_token']);
}
// redirect the user back to the same page if it has "code" GET variable
if (isset($_GET['code'])) {
header('Location: ./');
}
//header('Location: http://localhost/facebook/i.php');
} else {
// replace your website URL same as added in the developers.facebook.com/apps e.g. if you used http instead of https and you used non-www version or www version of your website then you must add the same here
$loginUrl = $helper->getLoginUrl('http://localhost/facebook/index.php', $permissions);
echo '<center><a class="link" href="' . $loginUrl . '"></a></center>';
}
?>