Facebook:Blank Screen on FB Login

邮差的信 提交于 2019-12-10 13:12:57

问题


suddenly I am getting a strange thing happening in my application when trying to login via facebook. The facebook connect popup dialog will show a blank screen after asking for login details. Normally I would expect to see the window close, and then the site itself would carry on, however it appears to have hung.

I am using Javascript SDK on Localhost

Here is the code I'm using (copying directly from the facebook documentation):

window.fbAsyncInit = function () {
    FB.init({ appId: fbAppId,
        status: false,
        cookie: true,
        xfbml: true
    });

};

(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));



$(document).ready(function () {


    $("#fb_button_login").click(function () {


        FB.login(function (response) {
            if (response.authResponse) {
                console.log('Welcome!  Fetching your information.... ');
                FB.api('/me', function (response) {
                    console.log('Good to see you, ' + response.name + '.');
                });
            } else {
                console.log('User cancelled login or did not fully authorize.');
            }
        });


    });

});

Some other notes:

  • This appears to be happening on all browsers.
  • I have researched all other posts and can't seem to find a solution that works for me
  • There are no error messages showing up in console
  • When developing I use a separate FB app ID that I have setup specifically for localhost with the designated port I'm using (has worked fine for more than 12 months)
    • I do not have sandbox mode enabled

The URL it appears to hang on is here

Thanks guys.


回答1:


Seems like a bug: https://developers.facebook.com/bugs/241915819261223?browse=search_4ff2ead131a032989098325

From the comments in the above link, you can try running your app on port 80 and avoid the port part in the url




回答2:


Try the following code

<html>
<body>
<div id="fb-root"></div>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js" ></script>
<script>

FB.init({appId: fbAppId, status: true, cookie: true, xfbml: true});
$(document).ready(function () {
    $("#fb_button_login").click(function () {
        FB.login(function (response) {
            if (response.authResponse) {
                console.log('Welcome!  Fetching your information.... ');
                FB.api('/me', function (response) {
                    console.log('Good to see you, ' + response.name + '.');
                });
            } else {
                console.log('User cancelled login or did not fully authorize.');
            }
        });


    });
});

</script>
<a href="javascript://" id="fb_button_login">Login</a>
</body>
</html>


来源:https://stackoverflow.com/questions/11293494/facebookblank-screen-on-fb-login

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!