For creating logout from facebook we need the facebook javascript SDK.
Code snippets to logout from Facebook is given below :
<script>window.fbAsyncInit = function() {
FB.init({
appId : "FACEBOOK_APPLICATION_ID",
status : true,
cookie : true,
xfbml : true,
oauth : true
});
FB.getLoginStatus(function(response) {
if (response && response.status === 'connected') {
FB.logout(function(response) {
/** Afer logout, Refresh the Page **/
console.log('Logout Successfully.');
document.getElementById('currentStatus').innerHTML='Logout from facebook Successfully.';
//document.location.href='/';
/** Afer logout, Refresh the Page **/
});
}else{
//document.location.href='/';
document.getElementById('currentStatus').innerHTML='You are NOT LOGIN in Facebook.';
console.log('You are not login in Facebook.')
}
});
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
<h2 id="currentStatus">
Please wait...</h2>
0 Comment(s)