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

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

问题描述

使用有效的Facebook应用程序调用FB.getLoginStatus时,响应状态始终是未知的。确切的回应是{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>




示例URL:
http://media.tuentifotos.com/simple_test.html






这里是Facebook App Settings的屏幕截图。

解决方案

Chrome在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天全站免登陆