我有一个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主页加载到一个框架中,但不能因为被禁止.那我该怎么解决呢?为什么不注销()可以为我工作?
我的代码
// 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); }); }
解决方法
这个解决方案适用于我:
>转到您的Facebook应用程序中的“设置”选项卡,然后在“基本”选项卡向下滚动到“添加平台”
>点击添加平台,选择网站
>添加您的网站的网址(对于我来说,与重定向URI上的高级选项卡上添加的URL相同)
>保存更改并再次测试.
另外我做了一个YouTube视频来解决这个问题:https://www.youtube.com/watch?v=7CNpLgwa0-c
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。