如何使用 Facebook API 获取我朋友的朋友?
我有一个应用程序,用户可以使用 Facebook 凭据进行自我注册。现在考虑我获得离线访问权限的每个用户。
我知道我可以使用 Graph API 获取我的朋友。对于每个注册的用户,我将 fbuid 存储到我的数据库中。
现在我在想,因为我有朋友注册了我的应用程序,并且这些用户会允许我的应用程序进行离线访问。我想到将我的朋友放入一个数组中,然后找到数组中每个朋友的朋友并加入所有朋友。这里的问题是我需要删除重复的 Facebook 用户(可能是太多的朋友)朋友的列表)并获取朋友的朋友的最终列表。
那么我可以使用 FQL 获取我朋友的朋友吗 或图表API?
我通过搜索朋友的朋友在 Stack Overflow 上搜索/阅读了很多主题,但没有用。
注意:这不是 StackOverflow 上已经发布的类似问题。请完整阅读以理解此问题。
I have an application where users can register themselves using Facebook credentials. Now consider for every user I get the permission for offline access.
I know that I can fetch the friends of mine using the Graph API.. For every user registered, I store the fbuid into my database.
Now I'm thinking that as I have my friends who have registered into my application and those users would have permitted my application for offline access. I thought of getting my friends in an array and just find friends of each and every friend in the array and join all of them.. Here the problem is I need to remove the Facebook users who are repeated (may be a friends in too many friend's list) and get a final list of friends of friends..
So can I get the friends of my friend using FQL or Graph API?
I searched/read lots of topics on Stack Overflow by searching for friends of friends, but of no use.
Note: This is not the similar questions already posted on Stack Overflow. Please read fully to understand this question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法使用 FQL 表“朋友”来获取朋友的朋友,您需要为您没有的每个朋友提供有效的访问令牌。
您可以使用图形 API 轻松完成此操作,但可能需要很长时间。我猜 500 个朋友平均需要 20 分钟。您需要这样称呼:
首先为原始用户,然后为他的每一位朋友。
fields=id
参数将有助于减少您接收的数据量,但您可能还需要将限制设置得更高。将 &limit=5000 添加到图形查询中。为了节省时间,您可以使用批量请求 。首先调用原用户的好友连接,然后为其所有好友生成批量请求。
所有这些都会生成大量数据,因此即时执行可能不是一个好主意。
Facebook 无法为您对所有重复项进行排序,您需要使用您正在使用的编程语言手动执行此操作,但这应该是微不足道的。
祝你好运。
You can't use the FQL table 'friends' to get friends of friends, you need a valid access token for every friend which you don't have.
You can do this with the graph API easily, but it will probably take a long time. My guess is 20 minutes average for 500 friends. You will need to call this:
First for the original user, and then for every one of his friends. The
fields=id
parameter will help with the amount of data you receive, though you will probably need to set the limit higher too. Add &limit=5000 to the graph query.To save on time you can use Batch Requests. First call the friends connection for the original user, and then generate a batch request for all his friends.
All this will generate a lot of data, so doing it on the fly is probably not a good idea.
There is no way for Facebook to sort all the duplicates for you, you will need to do so manually with the programming language you are using, but that should be trivial.
Good luck.