使用新的JS SDK获取userID

时间:2011-12-10 11:37:20

标签: userid facebook-javascript-sdk

你会怎样做: strUserID = FB.getSession()。uid;
使用新的JS SDK?
登录后获取用户ID的简单调用?

1 个答案:

答案 0 :(得分:0)

参考:http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/

FB.getLoginStatus(function(response) {
  if (response.authResponse) {
    // logged in and connected user, someone you know
  } else {
    // no user session available, someone you dont know
  }
});

响应:

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