简体   繁体   English

在Django中找到用户的Facebook朋友,他们也是我网站上的注册用户

[英]Find user's Facebook friends who are also registered users on my site in Django

I'm developing a Django site that has as a feature its own social network. 我正在开发一个具有自己的社交网络功能的Django网站。 Essentially, the site stores connections between users. 本质上,站点存储用户之间的连接。 I want users to be able to import their pre-existing Facebook connections (friends) to my site, so that they will automatically be connected to their existing Facebook friends who are users on my site. 我希望用户能够将其现有的Facebook连接(朋友)导入到我的网站,以便他们将自动连接到作为我的网站用户的现有Facebook朋友。

The way I envision doing this is by allowing users to login with Facebook (probably with something like django-socialauth), and store the user's Facebook ID in the database. 我设想这样做的方法是允许用户使用Facebook登录(可能使用django-socialauth之类的登录),并将用户的Facebook ID存储在数据库中。 Then, each time a user clicks the "find friends from Facebook" button, I could query the Facebook API to see if any of my existing users are their friends. 然后,每次用户单击“从Facebook查找朋友”按钮时,我都可以查询Facebook API,以查看我现有的用户是否是他们的朋友。 What's the best way to do this? 最好的方法是什么? I could use FQL and get a list of their friend's Facebook IDs, and then check that against my users', but that seems really inefficient at scale. 我可以使用FQL并获取他们朋友的Facebook ID列表,然后根据我的用户的ID进行检查,但这在规模上似乎效率很低。 Is there any way to do this without running through each of my users, one by one, and checking whether their Facebook ID is in the user's friends list? 是否有任何方法可以不逐个浏览我的每个用户并检查其Facebook ID是否在用户的朋友列表中?

Thanks. 谢谢。

“查找朋友”按钮确实效率低下,在用户注册时我只会搜索一次数据库。

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

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