【发布时间】:2014-04-15 09:33:30
【问题描述】:
我有一个localhost 网站和带有FB.logout() 的脚本。经过一些操作后,它无法让我退出,我在控制台中看到下一条错误消息:
Refused to display 'https://www.facebook.com/home.php' in a frame because it set 'X-Frame- Options' to 'DENY'.
我搜索了所有 StackOverflow 并没有找到任何可行的解决方案。网络检查器显示 home.php 附近的查询已取消。
所以我知道该脚本试图在框架中加载 Facebook 主页,但它不能,因为它被禁止。那么我该如何解决呢?为什么logout() 对我不起作用?
我的代码
// Facebook Basic Example
window.fbAsyncInit = function() {
FB.init({
appId : '579651098766258',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Event.subscribe('auth.authResponseChange', function(response) {
if (response.status === 'connected') {
testAPI();
} else if (response.status === 'not_authorized') {
FB.login();
} else {
FB.login();
}
});
};
(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));
function testAPI() {
FB.api('/me', function(res) {
console.log(res);
setTimeout(function(){
FB.logout(); // <-- ERROR
}, 2000);
});
}
【问题讨论】:
-
你能发布你的代码吗?
-
@AdamAzad 已添加到我的帖子中
-
我用我的应用程序尝试了代码,它运行良好!可能这是一个错误
-
你在本地主机或网络服务器上尝试过吗? @AdamAzad
-
我也有同样的问题,你找到解决办法了吗?
标签: javascript facebook oauth-2.0 facebook-javascript-sdk