Twitter Follow Backs for Large Numbers of Followers
Here is a python script on GitHub for implementing twitter follow backs, called twitter-bot. This continues the seminal post on the creation of our blog. The best way to implement the follow back script is a cron job, or a scheduled task on Windows.
There are several follow back bots on the net, but most of them only work for fairly small numbers of followers. This is a bot for twitter follow backs that has been functioning with an excess of 15k followers.
Before implementing the follow-back bot, be sure to create a Twitter app and insert your keys and tokens in TwitterBot.py. Once the keys are in place, edit FOLLOW_LIST.txt to add the Twitter IDs of the people you want to follow, but don’t require them to follow you back. In other words, FOLLOW_LIST.txt hold the IDs of whom you are fans.
The key to supporting large numbers of followers is to NOT use the following type of friends loading as it requires too many API calls.
# Don't do this if you have large numbers of followers for follower in tweepy.Cursor(api.followers).items(): follower.follow()
Instead, iterate through api.friends_ids in pages:
# Use this mechanism if you have large numbers of followers for page in tweepy.Cursor(api.friends_ids, id = me.id).pages(): followingIds.extend(page)
Pending follow requests are currently propagated forever as I haven’t quite decided what to do yet about “Pending” follow requests. The “Pending” follow requests have to be confirmed by the followee. Currently, TwitterBot checks all relationships between people I’m not following, and if a follow request is pending – it will not re-request a follow.
The disadvantage to maintaining the Pending requests is that it uses API requests to determine it is still pending. At some number of Pending follow requests they will begin to reduce the effectiveness of Twitter-Bot by taking up valuable API requests.
The ideal handling of Pending requests is to give them a timeout. This will allow followers that actually perform the follow confirmation or denial step enough time to get to their requests. However, after the timeout, the follow request can be cancelled. This should free up quite a large number of API requests to push the number of followers even higher.