FB.getLoginStatus always returns status='unknown'

一笑奈何 提交于 2019-12-30 11:27:28

问题


If I am logged into facebook.com, I expect a call to FB.getLoginStatus will return a status='not_authorized'. Instead it returns status='unknown', even if I pass true for the 'force' parameter.

If I call FB.login, and then call FB.getLoginStatus, I get status='connected'. Makes sense.

If I call FB.login, reload the page, and then call FB.getLoginStatus, I get status='unknown'. Does not make sense. If I add 'true' as the second parameter (i.e. force), I still get status='unknown'. (I expect status='not_authorized' in this case.)

There doesn't seem to be a way to get status='not_authorized' in practice.

Am I doing something wrong? Is this a bug in FB.getLoginStatus or its documentation?

Here is a minimal test page: http://pastebin.com/NqiBXni2

Context:

I am writing a website widget that displays posts for a public Facebook page. (This can be accessed without prompting the user via an app access token.) Each post has a "Like" / "Unlike" link. In order to determine whether to display "Like" or "Unlike", I need to know what the browsing user's Facebook ID is so that I can check whether it is in the post's list of likes.


回答1:


Maybe you have third party cookies disabled.




回答2:


And to elaborate slightly on David's answer, Facebook describes this as a "by design" result when 3rd party cookies are disabled.

Unfortunately, I'm not sure of the most graceful way of handling this -- at least in my site, I need an oath token to load some data.




回答3:


I had similar issue, even when the 3rd party cookie is not disabled. What I did to bypass is: if I get 'unknown' response, I will call FB.login and inside that call the FB.loginStatus again. This time, FB returned correct value.



来源:https://stackoverflow.com/questions/9337619/fb-getloginstatus-always-returns-status-unknown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!