简体   繁体   English

如何使用Facebook PHP SDK 3.0在单个请求中获取所有朋友的个人资料?

[英]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. 我正在尝试检索我的所有朋友,特别是我希望获取每个朋友的位置信息(hometown_location和location),以便将它们放在地图上。 I've tried the following code, which throws an error: Some of the aliases you requested do not exist: ids=8689768,86576659,898676 (etc) 我尝试了下面的代码,它会抛出一个错误:你请求的一些别名不存在: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()) FQL查询怎么样: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 返回也是空值但没有异常,还必须有一种通过FQL查询过滤空值的方法

Try it here: 试试吧:

https://developers.facebook.com/tools/explorer 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()) 使用URL: https ://graph.facebook.com/fql?q = SERECT uid,name,hometown_location,current_location FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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