I'l*_*ack 10 javascript php facebook facebook-oauth
我正在尝试将Facebook登录系统实施到我的网站中.
当它尝试连接到Facebook时,我从控制台日志中收到错误:
Unsafe JavaScript attempt to access frame with URL https://s-static.ak.fbcdn.net/connect/xd_proxy.php?xxxxxxxxxxxxxxxx
Run Code Online (Sandbox Code Playgroud)
我正在使用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>
Run Code Online (Sandbox Code Playgroud)
Facebook登录按钮:
<div class="fb-login-button" data-perms="email">Login with Facebook</div>
Run Code Online (Sandbox Code Playgroud)
我从本地主机测试-我有我的注册在Facebook网站开发的应用程序(网站网址:http://localhost)
如何解决这个问题?或者我应该使用PHP SDK?
编辑:当我上传到具有公共域的服务器时出现同样的问题.
当我实现fileglu时出现此错误,它可能是CORS错误,因为您正在本地主机上运行。尝试在 Facebook 上运行,你可以用下面的代码替换下半部分吗:
(function() {
var e = document.createElement('script');
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js#appId=<your-app-id>&xfbml=1';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
Run Code Online (Sandbox Code Playgroud)
我还在 FB.init() 页面中启用了 Oauth 2.0 和自定义通道。请参阅: http: //fbdevwiki.com/wiki/FB.init了解更多信息。
| 归档时间: |
|
| 查看次数: |
16576 次 |
| 最近记录: |