Fb.Connect not defined error while implementing FB logout
I am trying to implement a facebook logout functionality for my django app. Facebook login works just fine for me. Now i need to logout and clear the sessions somehow. FOr that i was trying to do with the code below, but its throwing 'FB.Connect not defined ' error. Can somebody pleas look at my code and give me a solution ?
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : 'xxx',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
</script>
<script>
function logout(){
FB.logout(function(response) {
// user is now logged out
location.href = '/user_sessions/new';
});}
// handle a session response from any of the auth related calls
function handleFBSessionResponse(response) {
/*
//Check the facebook login status
alert("handleFBSessionRespons开发者_JS百科e(), "
+ "\nresponse.status="+response.status
+" \nresponse.session="+response.session
+" \nresponse.perms="+response.perms);
*/
//if we do have a non-null response.session, call FB.logout(),
//the JS method will log the user out
//of Facebook and remove any authorization cookies
FB.logout(handleFBSessionResponse);
}
</script>
<a href="javascript:logout();">Logout</a >
Or is there any other straight forward easy way to implement it, if so please post that code here.
FB.logout(handleFBSessionResponse);
It seems weird that you are passing the callback function inside itself. Try to do something like that instead:
FB.logout(function(response) {
// user is now logged out
location.href = '/user_sessions/new';
});
And remove the other location.href reference in your code.
i got it working with this
<a href="http://m.facebook.com/logout.php?confirm=1&next=http://10.1.0.90:8080/registrationForm" >Sign Out</a>
精彩评论