FB.getLoginStatus returns status unknown

前端 未结 10 1270
不思量自难忘°
不思量自难忘° 2020-12-05 14:20

When calling FB.getLoginStatus using a valid Facebook App the response status is always unknown. Exact response is {authResponse: undefined, status: \"unknown\"}.

         


        
10条回答
  •  醉酒成梦
    2020-12-05 14:50

    When I checked, the status is showing "not_authorized" and that's fine, since I've not authorized the app yet.

    To complete the flow, you should add the FB.login whenever user id is not authorized or not logged-in to facebook:

    window.fbAsyncInit = function(){
        FB.init({ appId:'{APP-ID}', status:true,  cookie:true, xfbml:true});
        FB.getLoginStatus(function(response){
            if (response.status === 'connected') {
               //proceed
            } else if (response.status === 'not_authorized') {
               login();
            } else {
              login();
            }
        });
    };
    
    function login(){
       FB.login(function(response) {
          if (response.authResponse) {
             // proceed
          } else {
             // not auth / cancelled the login!
          }
       });
    }
    

提交回复
热议问题