tags:

views:

59

answers:

2

how can i get firstname and last name of facebook user while using f-connect? i can login using api. but i couldnt get firstname and lastname of logged in user.

+1  A: 

You have to invoke users.getInfo. In PHP, you would do it like this:

$userId = 1234567;
$fb = new Facebook(FACEBOOK_API_KEY, FACEBOOK_SECRET);
$fb->api_client->users_getInfo($userId, 'name, pic_square, first_name');

You can check the function's documentation here.

Antoine Aubry
+1  A: 
$client = new FacebookRestClient(API_KEY, SECRET_KEY, SESSION_KEY);
$userinfo = $client->users_getInfo($client->users_getLoggedInUser(), array('first_name','last_name'));
echo $userinfo[0]['first_name'] . ' ' . $userinfo[0]['last_name'];
Matt McCormick