【发布时间】:2011-12-22 05:12:29
【问题描述】:
我正在尝试在我的网站中实施 Facebook 登录系统。
当它尝试连接到 facebook 时,我从控制台日志中收到一个错误:
Unsafe JavaScript attempt to access frame with URL https://s-static.ak.fbcdn.net/connect/xd_proxy.php?xxxxxxxxxxxxxxxx
我正在使用 JavaScript SDK
我在body 标签中添加了这个:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxxxxxxxx',
status : true,
cookie : true,
xfbml : true
});
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
Facebook 登录按钮:
<div class="fb-login-button" data-perms="email">Login with Facebook</div>
我正在从 localhost 进行测试 - 我已经在 facebook 开发应用程序上注册了我的网站(网站 URL:http://localhost)
如何解决这个问题?还是我应该使用 PHP SDK?
编辑:当我上传到公共域的服务器时,同样的问题。
【问题讨论】:
-
您的脚本受到同源策略的阻碍 - en.wikipedia.org/wiki/Same_origin_policy
-
那么解决方法是什么?我正在使用 Chrome
-
与过去使用 Facebook API 的其他人交谈,以及在下面的一些答案中提到的内容,似乎从本地主机进行的测试有问题。尝试设置一个非本地主机测试服务器。
-
我在 Google +1 按钮上也看到了这个错误。它是特定于 chrome 的。 stackoverflow.com/questions/5660116/…
-
已知的 Chrome 问题。不要像我试图解决这个问题那样浪费时间:)
标签: php javascript facebook facebook-oauth