Balaji
Balaji

Reputation: 123

Collecting follower/friend Ids of large number of users - Twitter4j

I'm working on a research project which analyses closure patterns in social networks. Part of my requirement is to collect followers and following IDs of thousands of users under scrutiny.

I have a problem with rate limit exceeding 350 requests/hour. With just 4-5 requests my limit is exceeding - ie, when the number of followers I collected exceeds the 350 mark. ie, if I have 7 members each having 50 followers, then when I collect the follower details of just 7 members, my rate exceeds.(7*50 = 350).

I found a related question in stackoverflow here - What is the most effective way to get a list of followers using Twitter4j?

The resolution mentioned there was to use lookupUsers(long[] ids) method which will return a list of User objects... But I find no way in the API to find the screen names of friends/followers of a particular "User" object. Am I missing something here.. Is there a way to collect friends/followers of thousands of users effectively?

(Right now, I'm using standard code - Oauth authentication(to achieve 350 request/hour) followed by a call to twitter.getFollowersIDs)

Upvotes: 1

Views: 1818

Answers (1)

Terence Eden
Terence Eden

Reputation: 14304

It's fairly straightforward to do this with a limited number of API calls.

It can be done with two API calls.

Let's say you want to get all my followers

https://api.twitter.com/1/followers/ids.json?screen_name=edent

That will return up to 5,000 user IDs.

You do not need 5,000 calls to look them up!

You simply post those IDs to users/lookup

You will then get back the full profile of all the users following me - including screen name.

Upvotes: 1

Related Questions