FB.getLoginStatus doesn't work?

前端 未结 2 551
梦如初夏
梦如初夏 2021-01-03 04:24

The FB.getLoginStatus function doesn\'t work for me for some reason - although it used to for some time. Very basic code below, and the alert never popups - looks like FB.ge

相关标签:
2条回答
  • 2021-01-03 04:36

    In which platform you are developing the application??If it is FBML then check FBJS-Facebook JavaScript.I think alert will not work in FBML application. I got this working..Just check

    <div id="fb-root"></div>
    <script type="text/javascript">
    window.fbAsyncInit = function() {
        FB.init({appId: 'APP_ID', status: true, cookie: true, xfbml: false});
    };
    (function() {
        var e = document.createElement('script');
        e.type = 'text/javascript';
        e.src = document.location.protocol +
            '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
    }());
    window.fbAsyncInit = function() {
         FB.init({appId: 'APP_ID', status: true, cookie: true, xfbml: true});
    
             /* All the events registered */
             FB.Event.subscribe('auth.login', function(response) {
                 // do something with response
                 login();
             });
             FB.Event.subscribe('auth.logout', function(response) {
                 // do something with response
                 logout();
             });
    
             FB.getLoginStatus(function(response) {
                 if (response.session) {
                     // logged in and connected user, someone you know
                     login();
                 }
             });
         };
    

    0 讨论(0)
  • 2021-01-03 04:52

    If your app is in Sandbox Mode see this bug: https://developers.facebook.com/bugs/240058389381072

    Also read the comments by Philip Bulley

    [...] Essentially sandboxed applications are invisible to non-app-developers. If there is no user currently logged into Facebook, Facebook will act as if your sandboxed application doesn't exist at all (FB obviously doesn't know you're an app developer, and thus the app is invisible!).

    This bug has been confirmed and assigned.

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