且构网

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

如何检查用户是否连接到Facebook?

更新时间:2023-11-28 12:08:16

CBroe是对的。您必须在客户端检查用户状态。
要添加一些细节到CBroe说什么,该文档给出了有用的例子。

CBroe is right. You have to check user status client-side. To add some details to what CBroe said, the document gives you useful example.

FB.getLoginStatus(function(response) {
  if (response.status === 'connected') {
    // the user is logged in and has authenticated your app
    var uid = response.authResponse.userID;
    var accessToken = response.authResponse.accessToken;
  } else if (response.status === 'not_authorized') {
    // the user is logged in to Facebook, 
    // but has not authenticated your app
  } else {
    // the user isn't logged in to Facebook.
  }
 });

我想将此作为对上一个答案的评论发表,以支持它,但评论表单忽略换行符...

I wanted to post this as a comment to previous answer to support it, but comment form ignores line breaks...