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
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'
));
1 Comment
Dante Cullari
What if there are 2 fields needed?