FQL, search for non-friend people and sort by mutual friends

霸气de小男生 提交于 2019-12-10 10:54:16

问题


I look for facebook users (any user, not just my friends or the friends of a specific user) with a pattern in the name, like this:

SELECT first_name,uid FROM user WHERE contains('pete')

This returns an array of people who's name contains "pete" (i.e. also "peter"). The number is quite high, so the results are of course truncated. I would like to grab, in this set (before the server-side truncation) who has most mutual friends with me (or with an arbitrary user id). However, issuing

SELECT first_name,uid FROM user WHERE contains('pete') AND mutual_friend_count > 1

gives and empty set (and no errors). I think the server truncates before applying the latter selection, as in normal SQL would happen, for performance reasons (or explicit limits I missed in the documentation).

I made a second attempt by trying to retrieve all the friends of friends of a userid, and then select on the name. However, retrieving friends of friends is not allowed (and technically difficult because some friends hide their list of friends, and this breaks the query).

I can see no other way to achieve my goal... is there any? (I mean: given a userid, search for users with highest number of mutual friends).


回答1:


Your best bet, since there's no FQL solution, would be to begin a database of your own following Facebook's best practices and policies of course. That way you can structure your data. Data can be kept current by setting up Facebook's Realtime updates API (https://developers.facebook.com/docs/reference/api/realtime/) to capture when new friendships are made.




回答2:


I just tried it with "order by mutual_friend_count desc" and it worked. So the query needs to be:

SELECT first_name,uid FROM user WHERE contains('pete') order by mutual_friend_count desc



来源:https://stackoverflow.com/questions/10587789/fql-search-for-non-friend-people-and-sort-by-mutual-friends

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!