比较用户的Facebook / twitter朋友与网站的用户在Python / Django [英] Comparing user's facebook/twitter friends to site's users in Python/Django
问题描述
我正在建立一个简单的网站,用户将他们的Twitter帐户连接到注册。我想创建一个界面,显示他们的Twitter朋友已经在使用该网站。
所以我可以得到一个用户的Twitter朋友的列表,一个网站用户列表(所有这些用户名都是twitter屏幕名称,但我想知道最有效的方法来比较这些列表,并创建一个具有共同点的变量。
除此之外,由于Twitter API返回ID,所以在创建帐户时应该保存twitter用户的ID(除了用户名)吗?
谢谢推进!
intersection_set = set(list_a).intersection(list_b)
I'm wondering if someone could help guide the approach to this fairly common problem:
I'm building a simple site which a user connects their twitter account to sign up. I'd like to create an interface which shows them which of their twitter friends are already using the site.
So I can get a list the user's twitter friends, and a list of the site's users (which all have the twitter screen name as username, but I'm wondering the most efficient method to compare these lists and create a variable with the commonalities.
As an aside, given the Twitter API returns IDs, should I save the twitter user's ID (in addition to their username) when they create an account?
Thanks in advance!
Create Sets out of them, and use the intersection method:
intersection_set = set(list_a).intersection(list_b)
这篇关于比较用户的Facebook / twitter朋友与网站的用户在Python / Django的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!