0

为了检测 facebook 用户的在线/离线状态,我们使用方法 FB.getLoginStatus 方法。但是,paramater("response") 是什么意思,它来自下面的代码片段,参数 response 的意思是“FB.getLoginStatus(function(response)”行

          FB.getLoginStatus(function(response) {
            console.log(response);
            if (response.status === 'connected') {
                 // the user is logged in and has authenticated your
                 // app, and response.authResponse supplies
                 // the user's ID, a valid access token, a signed
                 // request, and the time the access token 
                 // and signed request each expire
                 var uid = response.authResponse.userID;
                 var accessToken = response.authResponse.accessToken;
                 console.log('User logged in and autenticated');
              } else if (response.status === 'not_authorized') {
                 // the user is logged in to Facebook, 
                 // but has not authenticated your app
                 console.log('User logged in, but not autorized');
              } else {
                 // the user isn't logged in to Facebook.
                 console.log('User not logged in');
              }
       }, true);
4

1 回答 1

2

您正在指定当 Facebook API 完成从服务器检索响应时要调用的函数。它将响应对象传递给您指定的函数。一个典型的反应是:

{
    status: 'connected',
    authResponse: {
        accessToken: '...',
        expiresIn:'...',
        signedRequest:'...',
        userID:'...'
    }
}

有关更多信息,请参阅facebook javascript 文档

于 2013-05-08T14:34:45.950 回答