我正在使用Facebook JS SDK让用户将他们的Facebook帐户连接到我的网站,但我遇到了一个奇怪的问题 .
当你按照这些步骤时似乎:
- connect for the first time with your fb account,
- authorize my app,
- go in another tab in your browser to the facebook website,
- remove my app,
- go back to my website tab in your browser
- click the connect button again
FB.getLoginStatus仍然将response.status作为'connected'返回,直到您刷新我的网站选项卡,然后它才将response.status显示为'not_authorized' .
甚至FB.login返回response.status为'connected',直到我刷新我的窗口(即使我在此之前调用FB.logout)
为什么我需要在显示为“not_authorized”之前刷新我的窗口,我该如何解决这个问题呢?
编辑:我正在使用OAuth功能
1 回答
那是因为SDK缓存了'FB.getLoginStatus'响应对象 .
如果要解决此问题,只需调用FB.getLoginStatus并将第二个参数设置为true .
https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/