0

我的代码如下所示

$(document).ready(function () {

   $.getScript('//connect.facebook.net/en_UK/all.js', function () {
    FB.init({
        appId: 'XXXXXXXXXXXX',
        channelUrl: '//localhost/channel.html',
        status: true, // check login status
        cookie: true, // enable cookies to allow the server to access the session
        xfbml: true  // parse XFBML
    });

    FB.getLoginStatus(function (response) {
        if (response.status === 'connected') {
            // the user is logged in and has authenticated your
            // app, and response.authResponse supplies
            // the user's ID, a valid access token, a signed
            // request, and the time the access token
            // and signed request each expire
            Dosomethinguseful();
        } else if (response.status === 'not_authorized') {
            // the user is logged in to Facebook,
            // but has not authenticated your app
        } else {
            // the user isn't logged in to Facebook.
            FB.login(function (response) {
                if (response.session) {
                    dosomething();
                }
            });
        }
    });
   });
});

上面的代码在 safari 和 firefox 上效果很好。但是,在 chrome 上我看不到任何事情发生。调试显示没有错误。

需要帮忙。

是否有使用 jquery 调用 FB auth 的工作示例?

===========

尝试了来自http://geekswithblogs.net/ptahiliani/archive/2013/08/23/facebook-login-authentication-example.aspx的代码。它也不适用于 chrome :(。我收到以下错误

'Blocked a frame with origin "http://www.facebook.com" from accessing a frame with origin "https://s-static.ak.facebook.com".  The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "https". Protocols must match.'
4

1 回答 1

0

Maybe an old question but this happened to me recently.

We found when using a self signed certificate we would get a grey "broken" screen in facebook. However, when visiting the site directly (ie not via facebook) and we accept this illegit certificate THEN visited the facebook app it worked fine.

Seems Chrome won't ask you to continue if it detects an invalid cert when pulling in page resources via HTTPS. But it remembers if you accept one if requesting directly via HTTPS.

Good luck :)

于 2014-01-30T09:40:51.190 回答