简体   繁体   English

Facebook Graph API:获得所有朋友的喜欢

[英]Facebook Graph API: get all the friends' likes

I don't particularly fancy the idea of getting a list of friends with 'me/friends' and then iterating over the list to get likes for a particular friend with '%id%/likes' - this takes way to long. 我并不特别喜欢用“我/朋友”获取朋友列表,然后在列表中迭代以获得具有'%id%/ likes'的特定朋友的喜欢 - 这需要很长时间。

Is there a way to bulk query likes of users' friends in a single API call? 有没有办法在单个API调用中批量查询用户的朋友?

Thanks. 谢谢。

You can use FQL multi-query to get all at once, here is how: 您可以使用FQL多查询一次获取所有内容,具体方法如下:

{
"friends":"SELECT name, uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())",
"friendsLikes":"SELECT uid, page_id FROM page_fan WHERE uid IN (SELECT uid FROM #friends)",
"pages":"SELECT page_id, name FROM page WHERE page_id IN (SELECT page_id FROM #friendsLikes)"
}

You can test this in http://developers.facebook.com/tools/explorer/ 您可以在http://developers.facebook.com/tools/explorer/中进行测试
You are going to get three result sets one after another, list of friends, list of all of their likes together and then list of page names. 您将逐个获得三个结果集,朋友列表,他们所有喜欢的列表以及页面名称列表。
(Note that the query may take a while to execute, so you may want to put a LIMIT on the first line. After uid1 = me() put a LIMIT 5 for example, for testing...) (注意,查询可能需要一段时间才能执行,所以你可能想在第一行放置一个LIMIT。在uid1 = me()之后放一个LIMIT 5 ,例如,测试...)

Then include it in your code in whatever language/platform you are using, for example on iOS: http://developers.facebook.com/docs/howtos/run-fql-queries-ios-sdk/ 然后将其包含在您使用的任何语言/平台的代码中,例如在iOS上: http//developers.facebook.com/docs/howtos/run-fql-queries-ios-sdk/

You can also do the same query using the Graph API: 您也可以使用Graph API执行相同的查询:

https://graph.facebook.com/me/friends?fields=name,id,likes.limit(100).fields(id,name)&limit=100 https://graph.facebook.com/me/friends?fields=name,id,likes.limit(100).fields(id,name)&limit=100

This will solve the issue of the grouping. 这将解决分组问题。

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

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