我的代码如下所示
$(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的代码。它也不适用于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.'
答案 0 :(得分:0)
也许是一个老问题,但最近发生在我身上。
我们发现在使用自签名证书时,我们会在Facebook上看到一个灰色的“破损”屏幕。然而,当直接访问该网站(即不通过Facebook),我们接受这个非法证书,然后访问Facebook应用程序,它工作正常。
如果在通过HTTPS提取页面资源时检测到无效证书,Chrome似乎不会要求您继续。但它会记住,如果您直接通过HTTPS请求,则接受一个。
祝你好运:)