[英]Counting Twitter Retweets, Followers, Favorites
I am using Twitter's REST API V1.1 and I need to count the number of followers for a specific time period eg I want to see how many users followed me from Feb to August 2013. And same for the favorites, retweets etc. 我正在使用Twitter的REST API V1.1,我需要计算特定时间段内关注者的数量,例如,我想查看2013年2月至2013年8月有多少用户关注了我。收藏夹,转发等内容也是如此。
Any guidance you can provide to access this type of data? 您可以提供访问此类数据的任何指导吗?
Thanks 谢谢
Gem 宝石
Since you're using Rails, I would recommend using the Twitter gem by sferik . 由于您使用的是Rails,因此建议您使用sferik的Twitter gem 。 This gem interfaces directly with the Twitter v1.1 API, and has all the hooks you require: 这个gem直接与Twitter v1.1 API交互,并具有您需要的所有挂钩:
Followers -
client.friends("username")
关注者client.friends("username")
Favourites -
not sure
收藏夹 -not sure
Retweets -
client.mentions_timeline
转推client.mentions_timeline
I'm not sure how to only return time-constrained formats for this gem. 我不确定如何仅返回该gem的时间受限格式。 Failing a native ability to only pull the required data, you'll have to pull all the data & split for the required time period. 无法仅提取所需数据的本机功能,您将必须提取所有数据并在所需时间段内拆分。 However, this will very inefficient & expensive 但是,这将非常低效且昂贵
JS JS
This is the most efficient & "natural" way to access Twitter data in Rails. 这是在Rails中访问Twitter数据的最有效和“自然”的方式。 Failing that, there is a JS method called Twitterfetcher , which basically parases a Twitter Widget & allows you to display the content as required 失败的是,有一个称为Twitterfetcher的JS方法,该方法基本上将Twitter Widget置于伞下并允许您根据需要显示内容。
In addition to using the Gem provided in another answer, a solution to solving the number of users within a certain time span would be to first find your follower list. 除了使用另一个答案中提供的Gem,解决特定时间段内的用户数量的一种解决方案是首先找到您的关注者列表。 The gem must support this. 宝石必须支持这一点。 After authentication, make the get request as such 认证后,这样进行获取请求
GET followers/list
This will return a cursored collection of user objects for users following the specified user. 这将为跟随指定用户的用户返回用户对象的游标集合。 Read more Here 在这里阅读更多
The tricky part is the "created_at" field.. I'm not sure if this is a date of when the user created their twitter account, or the date of when the user started following you. 棘手的部分是“ created_at”字段。我不确定这是用户创建其Twitter帐户的日期还是用户开始关注您的日期。 You are most likely going to have to test this one for yourself, but I would start with reading through the twitter API documentation. 您很可能必须自己测试一下,但是我将从阅读Twitter API文档开始。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.