0

I have a problem to get the login status of the logged in user. The getLoginStatus Function will be not called. I want to get the access token to get the user data. I tried with my own APP-ID and with a game APP-ID (298553513572593). Above you can see my code:

<body>
    <div id="fb-root"></div>
    <script type="text/javascript">
        // Load the SDK asynchronously
        (
        function(d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) return;
            js = d.createElement(s); js.id = id;
            //js.src = "http://connect.facebook.net/de_DE/all.js";
            js.src = "http://connect.facebook.net/de_DE/all.js#xfbml=1&appId=APP_ID";
            fjs.parentNode.insertBefore(js, fjs);
        }
        (document, 'script', 'facebook-jssdk')
    );

        function login() {
            FB.login(function(response) {
                if (response.authResponse) {
                    // connected
                } else {
                    // cancelled
                }
            });
        }

        window.fbAsyncInit = function() {
            // init the FB JS SDK
            FB.init({
                appId      : 'APP_ID',                          
                status     : true,                                      
                cookie     : true,
                xfbml      : true 
            });

            // Additional initialization code such as adding Event Listeners goes here                      
            FB.getLoginStatus(function(response) {
                alert(response);
                if (response.status === 'connected') {
                    // connected
                    var uid = response.authResponse.userID;
                    var accessToken = response.authResponse.accessToken;
                } else if (response.status === 'not_authorized') {
                    // not_authorized
                    login();
                } else {
                    // not_logged_in
                    login();
                }
            });
        };
    </script>
    <div>
        <fb:login-button show-faces="true" width="200" max-rows="1"></fb:login-button>
    </div>
</body>

The Html-Tag has the attribute xmlns:fb="http://ogp.me/ns/fb#"

2
  • any errors on the console? Apr 23, 2013 at 10:28
  • I get following message: Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one o Apr 23, 2013 at 11:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.