forked from AaryaDandapur/ElevateTrend2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
84 lines (75 loc) · 3.09 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Facebook Login Integration</title>
</head>
<body>
<h2>Add Facebook Login to your webpage</h2>
<!-- Set the element id for the JSON response -->
<p id="profile"></p>
<!-- Add the Facebook SDK for Javascript -->
<script>
(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 = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
window.fbAsyncInit = function() {
FB.init({
appId : '826035332924514',
xfbml : true,
version : 'v13.0'
});
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
FB.api('/me', {fields: 'name, email'}, function(response) {
document.getElementById("profile").innerHTML =
"Good to see you, " + response.name + ". I see your email address is " + response.email;
});
} else {
FB.login(function(response) {
if (response.authResponse) {
FB.api('/me', {fields: 'name, email'}, function(response) {
document.getElementById("profile").innerHTML =
"Good to see you, " + response.name + ". I see your email address is " + response.email;
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {scope: 'email', redirect_uri: 'https://aaryadandapur.github.io/ElevateTrend2/'});
}
});
};
</script>
<!-- Button to trigger Facebook login -->
<div id="spinner" style="background: #4267b2; border-radius: 5px; color: white; height: 40px; text-align: center; width: 250px;">
Loading
<div class="fb-login-button"
data-max-rows="1"
data-size="large"
data-button-type="continue_with"
data-use-continue-as="true"></div>
</div>
<script>
var finished_rendering = function() {
console.log("finished rendering plugins");
var spinner = document.getElementById("spinner");
spinner.removeAttribute("style");
spinner.removeChild(spinner.childNodes[0]);
};
FB.Event.subscribe('xfbml.render', finished_rendering);
</script>
<!-- Fetch and display the access token -->
<script>
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
console.log(response.authResponse.accessToken);
}
});
</script>
</body>
</html>