2012-01-05 98 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. 
    } 
});