2011-04-08 3 views
0

내 장고 앱에 대한 페이스 북 로그 아웃 기능을 구현하려고합니다. 페이스 북의 로그인은 나를 위해 잘 작동합니다. 이제 로그 아웃하고 어떻게 든 세션을 지울 필요가 있습니다. 내가 아래 코드를 사용하려고했으나 'FB.Connect not defined'오류가 발생했습니다. 누군가 내 코드를보고 해결책을 제시 할 수 있습니까?FB 로그 아웃을 구현하는 동안 Fb.Connect가 정의되지 않았습니다.

<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("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 > 

또는 구현하기 쉬운 다른 간단한 방법이 있습니까? 그렇다면이 코드를 여기에 게시하십시오.

답변

0

내가는 "FB.logout는 함수가 아닙니다"나에게이 오류를 준 것이이

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

그 자체 안에 콜백 함수를 전달하는 것이 이상하게 보입니다. 그 대신 다음과 같이하십시오.

FB.logout(function(response) { 
    // user is now logged out 
    location.href = '/user_sessions/new'; 
}); 

그리고 코드에서 다른 location.href 참조를 제거하십시오. 내가 방법 '기능 handleFBSessionResponse (응답)를'제거해야한다

+0

작업있어? –

+0

코드를 변경했습니다. 컨트롤이 Fb.connect.logout() 내부로 들어 가지 않습니다. 호출하는 것이 올바른 방법입니까? –

관련 문제