我想获得在Twitter4j使用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小时后运行代码并获取相同的错误消息。我不知道为什么。谢谢你的帮助。
这是一个twitter问题,而不是Twitter4J问题。 Twitter4J只是调用Twitter API。您的Twitter帐户是否已被列入黑名单?它被禁止了吗?可能Twitter已停止向您提供太多电话的数据? –
该帐户未被列入黑名单或被禁止。有可能twitter已停止向我提供超过一天的数据吗? – Matt