注意 我阅读了有关此问题的所有相关问题,但找不到解决问题的方法。
Facebook:不安全的 JavaScript 问题(document.domain 值应该相同)
我正面临被阻止的框架 facebook api 问题:
Blocked a frame with origin "https://www.facebook.com" from accessing a frame with origin "http://static.ak.facebook.com". The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "http". Protocols must match.
我遵循了 facebook api 教程,并且正在使用此代码。
window.fbAsyncInit = function() {
FB.init({
appId : 'appID',
status : true,
channelUrl : 'http://staging.mywebsite.com/login/channel',
cookie : true,
xfbml : true
});
FB.login(function(response) {
if (response.authResponse) {
console.log('done');
} else {
console.log('problem');
}
});
FB.Event.subscribe('auth.login', function(response) {
console.log('test reponse');
console.log(response);
});
};
(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));
/login/channel 包含:
$cache_expire = 60*60*24*365;
header("Pragma: public");
header("Cache-Control: max-age=".$cache_expire);
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$cache_expire) . ' GMT');
echo '<script src="//connect.facebook.net/en_US/all.js"></script>';
fb登录按钮:
<fb:login-button width="200" max-rows="1" scope="email,user_birthday,user_interests,user_likes,user_location,user_hometown,user_mobile_phone,user_address"></fb:login-button>
我也试过这个,但它没有解决问题:
channelUrl : '//staging.mywebsite.com/login/channel', //same issue
我错过了什么吗?或者也许我应该更改 fb 应用程序设置中的某些内容?