3

Why is it even though I have already authenticated my app, it still returns "unknown" in the response of FB.getLoginStatus()?

I have this code:

<html>
<head></head>
<body>
<div id="fb-root"></div>
<script>
    window.fbAsyncInit = function() {
        FB.init({
            appId      : '###',
            status     : true, // check login status
            cookie     : true, // enable cookies to allow the server to access the session
            xfbml      : true  // parse XFBML
        });

        //check status...
        FB.getLoginStatus(function(response) {
            console.log('The status of the session is: ' + response.status);
        });
    };

    // Load the SDK asynchronously
    (function(d){
        var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement('script'); js.id = id; js.async = true;
        js.src = "//connect.facebook.net/en_US/all.js";
        ref.parentNode.insertBefore(js, ref);
    }(document));

    // Here we run a very simple test of the Graph API after login is successful. 
    // This testAPI() function is only called in those cases. 
    function testAPI() {
        console.log('Welcome!  Fetching your information.... ');
        FB.api('/me', function(response) {
            console.log('Good to see you, ' + response.name + '.');
        });
    }
</script>
<a href="javascript:FB.login();">Login</a>
</body>
</html>

And I am expecting a result with this data:

{
  status: "connected",
  authResponse: {
    userID: "###",
    signedRequest: "###",
    expiresIn: "###",
    accessToken: "###"
  }
}

Is there any other way I can get the login status of the user in FB JS SDK? I already tried FB.Event.subscribe() but still the same. Nothing happens.. -_-

Jhon Andrew
  • 188
  • 3
  • 14

1 Answers1

0

DO NOT use "http" be your DEV HOST

Just use https instead of http and it works for me!

Ian
  • 74
  • 7