-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfacebook.html
47 lines (40 loc) · 1.35 KB
/
facebook.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
<html>
<head>
<title>My Facebook Login Page</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '524628860884309', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "http://connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
<button class="btn btn-success" id="fb-login">Login</button>
<script>
document.getElementById('fb-login').onclick = function() {
FB.login(function(response) {
console.log('FB.login callback', response);
if (response.status === 'connected') {
console.log('User is logged in');
} else {
console.log('User is logged out');
}
});
};
</script>
</body>
</html>