Php facebook登录阻止了一个框架问题
注意 我阅读了关于这个问题的所有相关问题,但我找不到解决问题的方法 我面临的是facebook api框架阻塞问题:Php facebook登录阻止了一个框架问题,php,javascript,jquery,facebook,facebook-login,Php,Javascript,Jquery,Facebook,Facebook Login,注意 我阅读了关于这个问题的所有相关问题,但我找不到解决问题的方法 我面临的是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
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.
我遵循了FacebookAPI教程,我正在使用这段代码
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));
/登录/频道包含:
$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应用程序设置中的某些内容 看起来您可能需要修改下面的代码才能通过https
(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 = "https://connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
另外,src=“//domain.com将继承协议。您可以尝试:
echo '<script src="https://connect.facebook.net/en_US/all.js"></script>';
echo';
也许这没有什么帮助,但我只是想让您知道,我一直在控制台中遇到这些错误。尽管如此,一切仍按预期运行,因此这只是一个丑陋的问题,而不是一个实际问题。换句话说,如果您遇到问题,这可能不是问题的原因……没错,我无法克服问题我到目前为止,但一切正常,但我仍然不喜欢产生错误的代码。因此我仍在努力寻找解决方案。还有一件事我注意到,这个问题发生在我使用staging.myserver.com时,当我将代码推到生产环境时,在我的实际myserver.com上消失了。
(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 = "https://connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
echo '<script src="https://connect.facebook.net/en_US/all.js"></script>';