How to get user information using facebook connection

How can I get the firstname and last name of a facebook user when using f-connect?

I can login using api, but I was unable to get the first and last name of the registered users.

+2


source to share


2 answers


You should call 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 documentation here .

+4


source


$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'];

      



+4


source







All Articles