1

Is there a Facebook Graph API query to return names of my friends if I provide a list of IDs? I know I can do it separately for each friend but obviously this would be faster.

2 Answers 2

3

Yes there is a way to get the names from friends connection of user

https://graph.facebook.com/me/friends?fields=name

Using PHP-SDK this can be done like this:

$facebook = new Facebook(array(...));
$facebook->api('/me/friends', array(
  'fields'=>'name'
));

If you want to pass the ids of users to get their names it may be done so:

https://graph.facebook.com/?fields=name&ids=userid_1,userid_2,userid_n

Or the same using PHP-SDK:

$array_of_user_ids = array(4,123,/*etc*/);
$facebook = new Facebook(array(...));
$facebook->api('/', array(
  'ids'=>implode(',', $array_of_user_ids);
  'fields'=>'name'
));
Sign up to request clarification or add additional context in comments.

1 Comment

What if there are 2 fields needed?
1

You can do it with

https://graph.facebook.com/me/friends

It returns friends names with their ids.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.