FB.getLoginStatus not calling its callback

后端 未结 11 1142
半阙折子戏
半阙折子戏 2021-02-18 13:11

The title really says it all. Under some (undetermined) conditions FB.getLoginStatus() just stops working and won\'t invoke the callback I gave it. The only interesting clues

相关标签:
11条回答
  • 2021-02-18 13:48

    On the new version of the Developer app, you have to make sure to have put the correct URL you are using to access the application in the Website field under the

    Select how your app integrates with Facebook

    section.

    0 讨论(0)
  • 2021-02-18 13:49

    I had similar problem with FB API. It turned out, that my Facebook App was misconfigured. Please make sure that this is not the case for you. My problem was that my "Site URL" param in FB application was pointing to https, but I was using http protocol for development. Any call against FB api after FB.init was not calling my callback functions. So the first thing to do should be to double check App config.

    Now, if some reason you depend on FB api but you wish to have a fallback option in case it;s inoperative - workaround with timer should be ok for you. Just set up a timer and disable it if FB Api gives you proper response. If not - fallback to some custom function which will perform some additional logic.

     function callFbApi() {
        var timeoutHandler = setTimeout(function() { requestFailed(); }, 1000);
    
        function requestFailed() {
            // When this happens, it means that FB API was unresponsive
            doSomeFallbackWork();
            alert('hey, FB API does not work!');
        }
    
        FB.getLoginStatus(function(response) {
            clearTimeout(timeoutHandler); // This will clear the timeout in case of proper FB call
            doSomeUsualWorkAfterFbReplies();
    
            return false;
        }, true);
     }
    
    0 讨论(0)
  • 2021-02-18 13:49

    Make sure the protocol is HTTPS and not HTTP.

    0 讨论(0)
  • 2021-02-18 13:50

    As others have posted, you must be accessing your site at the same URL that facebook expects. For example if facebook has a callback "example.com" but you're browser has "www.example.com", that can cause this problem.

    In addition, if third-party cookies are not allowed by your browser, you may also see this problem. Or you may see the callback erroneously reporting the user is not connected.

    0 讨论(0)
  • 2021-02-18 13:52

    Just posting a situation I had were calling FB.getLoginStatus got absolutely no response.

    My application is designed to run in a tab, and I only entered the Page Tab URLs on the app admin page, and not the App On Facebook (i.e. Canvas) URLs. The tab loads perfectly, but any calls to the FB JS SDK provoke no response.

    0 讨论(0)
  • 2021-02-18 13:53

    Maybe you are using the asynchronous call. The same thing happened when I called FB.init with window.fbAsyncInit. All I did was delay the FB.getLoginStatus with a setTimeout function

      window.setTimeout(checkLogStatus, 1000);
    
    
      function checkLogStatus(){
              alert("check");
              // fetch the status on load      
              FB.getLoginStatus(handleSessionResponse);
      }
    

    It seemed to work after that

    0 讨论(0)
提交回复
热议问题