且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

登录我的应用程序后如何检测用户登出Facebook?

更新时间:2022-06-17 07:35:41

回想起 em> getLoginStatus ,但强制往返于Facebook。看看以下代码:

Just recall getLoginStatus BUT forcing a roundtrip to Facebook. Look following code:

FB.getLoginStatus(function(response) {
  // some code
}, true);

查看最后一个参数设置为 强制往返。

Look the last parameter set to true to force the roundtrip.

从JS SDK文档:


您的应用程序的性能,而不是每次调用
检查用户的状态将导致请求到Facebook的
服务器。在可能的情况下,响应缓存。在
当前浏览器会话中,首次调用了 FB.getLoginStatus ,或者JS
SDK的初始状态为true:响应对象将被缓存
的SDK。随后调用 FB.getLoginStatus 将从
返回此缓存响应的数据。

To improve the performance of your application, not every call to check the status of the user will result in request to Facebook's servers. Where possible, the response is cached. The first time in the current browser session that FB.getLoginStatus is called, or the JS SDK is init'd with status: true, the response object will be cached by the SDK. Subsequent calls to FB.getLoginStatus will return data from this cached response.

这可能会导致用户登录的问题(或从)
自上次完整会话查找以来的Facebook,或者如果用户在其帐户设置中将
删除了您的应用程序。

This can cause problems where the user has logged into (or out of) Facebook since the last full session lookup, or if the user has removed your application in their account settings.

解决这个问题,您可以调用 FB.getLoginStatus ,将第二个
参数设置为true,以强制向Facebook的往返路线 - 有效地
刷新响应对象的缓存。
http://developers.facebook.com/docs/reference /javascript/FB.getLoginStatus/

To get around this, you call FB.getLoginStatus with the second parameter set to true to force a roundtrip to Facebook - effectively refreshing the cache of the response object. (http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/)