gpt4 book ai didi

php - Facebook登录阻止了一个框架问题

转载 作者:搜寻专家 更新时间:2023-10-31 22:05:49 24 4
gpt4 key购买 nike

注意我阅读了有关此问题的所有相关问题,但找不到解决问题的方法。

Facebook Login API HTTPS Issue

Facebook: Unsafe JavaScript issue (document.domain values should be same)

我面临着被阻止的框架 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

我错过了什么吗?或者我应该更改 Facebook 应用程序设置中的某些内容?

最佳答案

看来您可能需要修改下面的代码才能通过 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 将继承协议(protocol)。您可以尝试:

echo '<script src="https://connect.facebook.net/en_US/all.js"></script>';

关于php - Facebook登录阻止了一个框架问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18735446/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com