2012-01-05 96 views
-7

可能重复:
Information about current user in facebook知道当前登录用户的Facebook的ID

如何知道当前logge用户的Facebook的ID, getLoginStatusUrl将提供的网址,但我想的细节当前登录的用户.. 如何使用facebook php sdk获取此内容。 请指定要使用的功能和参数。

+1

你只是张贴同样的问题一个先前只是没有代码示例...请参阅在http答案:// Facebook的。 stackoverflow.com/questions/8718401/get-id-from-facebook-php-sdk和http://facebook.stackoverflow.com/questions/8738943/imformation-about-current-user-in-facebook – 2012-01-05 08:07:16

回答

0

使用PHP:

$facebook_user_id = $facebook->getUser(); 

使用Javascript SDK:

FB.getLoginStatus(function(response) { 
    if (response.status === 'connected') { 
    var uid = response.authResponse.userID; // this is the ID of the user 

    } else if (response.status === 'not_authorized') { 
    // the user is logged in to Facebook, 
    //but not connected to the app 
    } else { 
    // the user isn't even logged in to Facebook. 
    } 
});