Tutorial :How to get a list of *new* followers using the twitter API



Question:

I need to periodically return a list of all new followers of a twitter account (i.e. since the last time the list of followers was retrieved), but the Twitter API only seems to provide functionality for getting a list of all current followers of the account.

Apart from getting this full list every time and comparing it against a stored version of the last time it was retrieved, is there any other way to get hold of the new followers?

Sites such as divvoted.com, mrtweet etc must do this somehow! Am I missing something or does it just need the round-the-houses approach described above?


Solution:1

Yes, you have to keep the list of followers since last update, because twitter does not associate api clients to state. The definition of 'last time the list was retrieved' lacks 'by whom'.


Solution:2

You always can try to catch the mails from Twitter with the message: "... is following you on Twitter". This might be a bit harder than using the Twitter API and there is a chance of missing mails (in case mails are not delivered), but it will safe some valuable API calls. But this does not cover unfollowing...

If you try to do it the way you described yourself. The Twitter API returns the followers in order of "newer follower first", so on the first hit (a follower listed in your stored version of the list) you can stop looking for new followers.


Solution:3

I have recently started using Zapier for this.

They have a Zap which uses the Twitter API to get new followers (of you or any username that you wish monitor). The Zap monitors for new followers and can then add a record to Google Sheets, Trello, Slack etc.

It doesn't tell you who has unfollowed but you can always clash your follow lists with that of you full list.

It also triggers on a follow - so someone could follow, unfollow and follow again and appear on the list twice. Easy to manage though if you have your follower list.

Here is there documentation for this: https://zapier.com/zapbook/zaps/201/log-new-twitter-followers-google-spreadsheet/


Solution:4

For authorized users you can use Twitter Stream API for track new followers: https://dev.twitter.com/streaming/overview/messages-types#Events_event

I use it with C# library https://github.com/linvi/tweetinvi and code is very simple:

Auth.SetUserCredentials("CONSUMER_KEY", "CONSUMER_SECRET", "ACCESS_TOKEN", "ACCESS_TOKEN_SECRET");  var stream = Stream.CreateUserStream();  stream.FollowedByUser += (sender, args) =>  {      Console.WriteLine("You have been followed by " + args.User);  };  stream.StartStream();  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »