public Twitter getTwitter(int callCount) {
throttle(callCount);
return twitter;
}
private void throttle(int callCount) {
if (twitter.isRateLimited(KRequestType.NORMAL, callCount)) {
RateLimit rateLimit = twitter.getRateLimit(KRequestType.NORMAL);
rateLimit.waitForReset();
}
}
For simple calls everything is good, however I'm hitting some challenges in working with lists.
To get a list of the people I'm following, I assume something like this is necessary:
followedIdList=getTwitter(1).getFriendIDs();
followedUserList=getTwitter(100).bulkShowById(followedIdList); // 100 is the fetch batch size in Twitter.bulkShow2
If I'm following a lot of people, I may never be able to execute the second call because there doesn't appear to be any rate limit checking in Twitter.bulkShow2. And if it works, I would still be concerned about hard-coding the batch size, since in bulkShow2 it is a private variable that could change without notice.
A couple more examples...the question is, does it only use 1 api call, or is it 1 call + 1 call for every list returned:
myLists=getTwitter(1).getLists();
otherListsContainingMe=getTwitter(1).getListsContainingMe();
myListsContainingUser =getTwitter(1).getListsContaining(user.getScreenName(), true);
If I am unable to predict the number of api calls required, I have no idea how to rate limit properly!
Best,
George