How To Get More Followers?

Twitter API: Twitter4j: How to get all followers and friends?

  • Hi, I'm trying to get a complete set of followers and friends for a given user ... I'm using twitter4j and have the following code: //Getting followers                 long followerCursor = -1;                 IDs followerIds;                 do                 {                     followerIds = twitter.getFollowersIDs( userId, followerCursor);                     ResponseList<User> followers = twitter.lookupUsers(followerIds.getIDs());                                         for(User follower : followers)                     {                         db.insertFollowers                         (                             follower.getId(),                             userId,                             "@" + follower.getScreenName(),                             follower.getName(),                             follower.getLocation(),                             follower.getFollowersCount(),                             follower.getFriendsCount()                         );                     }                                     }while((followerCursor = followerIds.getNextCursor()) != 0); With this code i get the followers and with modification i can also get the list of friends but the problem is that i run into the API limit exception ... Is there another way to do this? If not, how can i modify this so i don't run into the exception. Thanks

  • Answer:

    To not run in rate limit Exception, I suggest you to make your program do regular pauses to not exceed those limits. You can use something like this: http://stackoverflow.com/questions/3342651/how-can-i-delay-a-java-program-for-a-few-seconds Info on rate limits are here: https://dev.twitter.com/docs/rate-limiting/1.1/limits Remember that each limit is calculated for a specific type of query, so you can for example get 15 users and 180 tweets in the same time slot (15 minutes), as i saw. You can even connect with different DEV accounts/keys (with different IP addresses) but you'll have to merge the data you get. Btw, if you really need informations at higher rates, you can take advantage of the fact that limits on tweets are much less time restrictive (about a tweet every 5 seconds). So you can try to download/serialize some tweets and manipulate their informations (they are a lot, not only related about the tweet text).

Salvatore Mamì at Quora Visit the source

Was this solution helpful to you?

Other answers

If you are looking for the data, BirdSong can help. We can provide an export of followers/following for any account. There is no monthly fee, just pay as you go.  http://www.birdsonganalytics.com/blog/2013/03/01/export-twitter-followers-with-birdsong-on-demand-reports/ I know this doesn't fix your code issue :-)

Jamie Riddell

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.