Facebook Javascript SDK: Basic Login and Logout example
<div id="fb-root"></div> | |
<script> | |
window.fbAsyncInit = function() { | |
FB.init({ | |
appId: 'xxxxxxxxxxxxx', | |
status: true, | |
cookie: true, | |
xfbml: true | |
}); | |
}; | |
// 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 = "//connect.facebook.net/en_US/all.js"; | |
ref.parentNode.insertBefore(js, ref); | |
}(document)); | |
function login() { | |
FB.login(function(response) { | |
// handle the response | |
console.log("Response goes here!"); | |
}, {scope: 'read_stream,publish_stream,publish_actions,read_friendlists'}); | |
} | |
function logout() { | |
FB.logout(function(response) { | |
// user is now logged out | |
}); | |
} | |
var status = FB.getLoginStatus(); | |
console.log(status); | |
</script> | |
<button onclick="javascript:login();">Login Facebook</button> | |
<br> | |
<button onclick="javascript:logout();">Logout from Facebook</button> |
This comment has been minimized.
This comment has been minimized.
When I use chrome, the process of logout costs a lot of time. |
This comment has been minimized.
This comment has been minimized.
I'm new in programming and I'm trying to add a facebook login into a a form, but I don't after many attempts why it doesn't work. Here is the codes, please I seriously need your help
Connectez-vous avec Facebook
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
i learned something new