简体   繁体   中英

How can I get all my friends profiles in a single request with the Facebook PHP SDK 3.0?

I'm trying to retrieve all my friends, specifically I want to get each friends location information (hometown_location and location) for the purpose of putting them on a map. I've tried the following code, which throws an error: Some of the aliases you requested do not exist: ids=8689768,86576659,898676 (etc)

 $friends = $facebook->api("/$user/friends");

 foreach($friends['data'] as $key => $friend) {

$friend_list .= ($key!=0) ? "," : "";
$friend_list .= $friend['id'];
 }

 $friend_profiles = $facebook->api("/ids=$friend_list");

Any ideas on how I can achieve this?

How about FQL query: SELECT uid, name, hometown_location, current_location FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me())

Returns also null values but no exception, there must also be a way to filtering null values via the FQL query

Try it here:

https://developers.facebook.com/tools/explorer

With the URL: https://graph.facebook.com/fql?q=SELECT uid, name, hometown_location, current_location FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM