|
|
|
|
@ -6,8 +6,8 @@
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
|
|
<button id="login" onclick="checkLoginState()">FaceBook Login</button>
|
|
|
|
|
<button id="login_out" onclick="loginOut()">FaceBook Login Out</button>
|
|
|
|
|
<button id="login" onclick="fbLogin()">FaceBook Login</button>
|
|
|
|
|
<button id="login_out" onclick="fbLoginOut()">FaceBook Login Out</button>
|
|
|
|
|
<div id="status">
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
@ -15,62 +15,43 @@
|
|
|
|
|
|
|
|
|
|
<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: 'v2.8'
|
|
|
|
|
version: 'v3.0'
|
|
|
|
|
});
|
|
|
|
|
$('#loginbutton,#feedbutton').removeAttr('disabled');
|
|
|
|
|
FB.getLoginStatus(updateStatusCallback);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function checkLoginState() {
|
|
|
|
|
// Facebook Login
|
|
|
|
|
function fbLogin() {
|
|
|
|
|
FB.getLoginStatus(function (response) {
|
|
|
|
|
statusChangeCallback(response);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function statusChangeCallback(response) {
|
|
|
|
|
console.log('statusChangeCallback');
|
|
|
|
|
console.log(response);
|
|
|
|
|
if (response.status === 'connected') {
|
|
|
|
|
$("#login").text('Login Out');
|
|
|
|
|
// Logged into your app and Facebook.
|
|
|
|
|
testAPI();
|
|
|
|
|
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) {
|
|
|
|
|
statusChangeCallback();
|
|
|
|
|
window.history.back();
|
|
|
|
|
|
|
|
|
|
}, {scope: 'public_profile,email'});
|
|
|
|
|
// The person is not logged into your app or we are unable to tell.
|
|
|
|
|
document.getElementById('status').innerHTML = 'Please log ' +
|
|
|
|
|
'into this app.';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loginOut() {
|
|
|
|
|
// Facebook LoginOut
|
|
|
|
|
function fbLoginOut() {
|
|
|
|
|
FB.logout(function (response) {
|
|
|
|
|
// Person is now logged out
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateStatusCallback(response) {
|
|
|
|
|
statusChangeCallback(response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function testAPI() {
|
|
|
|
|
console.log('Welcome! Fetching your information.... ');
|
|
|
|
|
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 + '!';
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|