You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.8 KiB
65 lines
1.8 KiB
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Facebook Login JavaScript Example</title>
|
|
<meta charset="UTF-8">
|
|
</head>
|
|
<body>
|
|
|
|
<button id="login" onclick="fbLogin()">FaceBook Login</button>
|
|
<button id="login_out" onclick="fbLoginOut()">FaceBook Login Out</button>
|
|
<div id="status">
|
|
</div>
|
|
|
|
<script src="jquery.min.js"></script>
|
|
|
|
<script>
|
|
|
|
// Facebook JavaScript SDK
|
|
$(document).ready(function () {
|
|
$.ajaxSetup({cache: true});
|
|
$.getScript('https://connect.facebook.net/en_US/sdk.js', function () {
|
|
FB.init({
|
|
appId: '176954776322838',
|
|
version: 'v3.0'
|
|
});
|
|
});
|
|
});
|
|
|
|
// Facebook Login
|
|
function fbLogin() {
|
|
FB.getLoginStatus(function (response) {
|
|
if (response.status === 'connected') {
|
|
// Logged into your app and Facebook.
|
|
FB.api('/me', {fields: 'name,last_name'}, function (response) {
|
|
console.log(response);
|
|
console.log('Successful login for: ' + response.name);
|
|
document.getElementById('status').innerHTML =
|
|
'Thanks for logging in, ' + response.name + '!';
|
|
});
|
|
console.log("login in");
|
|
} else {
|
|
FB.login(function (response) {
|
|
console.log(response);
|
|
}, {scope: 'public_profile,email'});
|
|
}
|
|
});
|
|
}
|
|
|
|
// Facebook LoginOut
|
|
function fbLoginOut() {
|
|
FB.getLoginStatus(function (response) {
|
|
console.log(response);
|
|
// if (response.status === 'connected') {
|
|
// FB.logout(function (response) {
|
|
// console.log('login out');
|
|
// // Person is now logged out
|
|
// });
|
|
// }
|
|
});
|
|
}
|
|
</script>
|
|
|
|
|
|
</body>
|
|
</html> |