2013-10-07 57 views
0

我的代码看起来如下FB登录,jQuery的不工作的铬

$(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很大。然而,在铬我没有看到任何事情发生。调试显示没有错误。

需要帮助。

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

===========

试过代码http://geekswithblogs.net/ptahiliani/archive/2013/08/23/facebook-login-authentication-example.aspx。这对铬也不起作用:(。我获得以下错误

'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.' 
+0

_“调试显示没有错误”_ - 所以你试过什么样的调试措施?你是否尝试按照文档推荐的方式嵌入SDK,而不是getScript mumbo-jumbo? – CBroe

+0

jquery必须这样做,或者如果我udnerstand正确:https://developers.facebook.com/docs/javascript/howto/jquery/ –

+0

啊,不知道FB建议这样做的事情与jQuery结合使用。那么,这留下了问题的第一部分。 – CBroe

回答

0

也许一个老问题,但这个发生在我身上最近。

我们使用的是自签名的证书时,我们会得到一个灰色的“破碎的发现“screen in facebook。但是,当直接访问该网站(即不通过Facebook),并且我们接受这个非法证书,然后访问它的facebook应用程序,它工作正常

似乎Chrome不会要求你继续,如果它检测到在通过HTTPS提取页面资源时无效的证书,但是如果您通过HTTPS直接请求,它会记住您是否接受其中的一个

祝你好运:)