我想让关注者getFollowersIds()
在 Twitter4j 中使用,但我得到了
ConnectionErrorException ... 超出速率限制
public static void main(String[] args) {
try {
Twitter twitter = TwitterFactory.getSingleton();
String[] srch = new String[]{"TechCrunch"};
ResponseList<User> users = twitter.lookupUsers(srch);
for (User user : users) {
UserHarvest us = new UserHarvest(6017542);
us.getFollowersIds();
try {
us.getContributors();
} catch (ConnectionErrorException ex) {
Logger.getLogger(UserHarvest.class.getName()).log(Level.SEVERE, null, ex);
}
}
} catch (TwitterException ex) {
Logger.getLogger(UserHarvest.class.getName()).log(Level.SEVERE, null, ex);
}
}
错误信息:
Exception in thread "main" harvest.twitterharvest.ConnectionErrorException: Connection could not have been established
at harvest.twitterharvest.WrapperTwitter4J.getFollowersIDs(WrapperTwitter4J.java:75)
at harvest.twitterharvest.UserHarvest.getFollowersIds(UserHarvest.java:106)
at harvest.twitterharvest.UserHarvest.main(UserHarvest.java:140)
Caused by: 429:Returned in API v1.1 when a request cannot be served due to the application's rate limit having been exhausted for the resource. See Rate Limiting in API v1.1.(https://dev.twitter.com/docs/rate-limiting/1.1)
message - Rate limit exceeded
code - 88
Relevant discussions can be found on the Internet at:
http://www.google.co.jp/search?q=92c30ec6 or
http://www.google.co.jp/search?q=19e1da11
TwitterException{exceptionCode=[92c30ec6-19e1da11], statusCode=429, message=Rate limit exceeded, code=88, retryAfter=-1, rateLimitStatus=RateLimitStatusJSONImpl{remaining=0, limit=15, resetTimeInSeconds=1384512813, secondsUntilReset=904}, version=3.0.4}
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:162)
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:61)
at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:89)
at twitter4j.TwitterImpl.get(TwitterImpl.java:1894)
at twitter4j.TwitterImpl.getFollowersIDs(TwitterImpl.java:409)
at harvest.twitterharvest.WrapperTwitter4J.getFollowersIDs(WrapperTwitter4J.java:73)
... 2 more
我明白了secondsUntilReset=904
。我在 1 小时后运行代码并收到相同的错误消息。我不知道为什么。谢谢你的帮助。