FB未定义在Django应用程序中实施Facebook注销的错误

时间:2011-04-07 10:59:29

标签: javascript python html django facebook

我正在尝试为我的django应用实现facebook注销功能。在我的应用中,用户可以使用app用户名或FB用户名登录。现在我想实现注销功能。 为此,我将此代码放在我的html页面中,但我得到'FB未定义'错误。有人可以帮我解决这个问题吗?

<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.getLoginStatus(handleFBSessionResponse);
            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("handleFBSessionResponse(), "
             + "\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 >

1 个答案:

答案 0 :(得分:0)

我使用了这个

<a href="http://m.facebook.com/logout.php?confirm=1&next=http://10.1.0.90:8080/registrationForm" >Sign Out</a>