简体   繁体   中英

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.

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 . This gem interfaces directly with the Twitter v1.1 API, and has all the hooks you require:

Followers - client.friends("username")

Favourites - not sure

Retweets - client.mentions_timeline

I'm not sure how to only return time-constrained formats for this 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

This is the most efficient & "natural" way to access Twitter data in Rails. Failing that, there is a JS method called Twitterfetcher , which basically parases a Twitter Widget & allows you to display the content as required

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. 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. You are most likely going to have to test this one for yourself, but I would start with reading through the twitter API documentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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