FB.getLoginStatus 返回状态未知 [英] FB.getLoginStatus returns status unknown

查看:31
本文介绍了FB.getLoginStatus 返回状态未知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用有效的 Facebook 应用调用 FB.getLoginStatus 时,响应状态始终未知.确切的响应是 {authResponse: undefined, status: "unknown"}.

<身体><div id="fb-root"></div><脚本>window.fbAsyncInit = function(){FB.init({ appId:'1484134468466778', status:true, cookie:true, xfbml:true});FB.getLoginStatus(函数(响应){控制台日志(响应);});};(功能(d){var js, id = 'facebook-jssdk';if (d.getElementById(id)) {return;}js = d.createElement('脚本');js.id = id;js.async = true;js.src = "//connect.facebook.net/en_US/all.js";d.getElementsByTagName('head')[0].appendChild(js);}(文档));


示例网址:http://media.tuentifotos.com/simple_test.html>


这是 Facebook 应用设置的屏幕截图.

解决方案

我在 Chrome 中遇到了这种情况,因为 Chrome 被配置为阻止第三方 cookie 和数据.

一旦我更改了配置,FaceBook 就可以毫无问题地让我登录我的应用.

  • Chrome 设置
  • 显示高级设置...
  • 隐私
  • 内容设置...
  • 取消选中阻止第三方 Cookie 和网站数据

When calling FB.getLoginStatus using a valid Facebook App the response status is always unknown. Exact response is {authResponse: undefined, status: "unknown"}.

<html>
<body>
    <div id="fb-root"></div>

    <script>
    window.fbAsyncInit = function(){
        FB.init({ appId:'1484134468466778', status:true,  cookie:true, xfbml:true});
        FB.getLoginStatus(function(response){
        console.log(response);
        });
    };

    (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>
</body>
</html>


Example URL: http://media.tuentifotos.com/simple_test.html


Here a screenshot of the Facebook App Settings.

解决方案

This was happening for me in Chrome, and was because Chrome was configured to block third-party cookies and data.

Once I made that configuration change, FaceBook is able to log me into my app without a problem.

  • Chrome Settings
  • Show advanced settings...
  • Privacy
  • Content settings...
  • uncheck Block third-party cookies and site data

这篇关于FB.getLoginStatus 返回状态未知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆