我想在java中使用twitter4j lib提取本周的所有推文。我尝试过这样做
try {
Query query = new Query("since:2013-04-01&until:2013-04-08");
QueryResult result;
do {
result = twitter.search(query);
List<Status> tweets = result.getTweets();
for (Status tweet : tweets) {
System.out.println("@" + tweet.getUser().getScreenName() + " - " + tweet.getText());
}
} while ((query = result.nextQuery()) != null);
System.exit(0);
但是,我最后收到了一条错误消息
403:The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits (https://support.twitter.com/articles/15364-about-twitter-limits-update-api-dm-and-following).
message - Missing or invalid url parameter
code - 195
那么,如何通过提供日期作为参数来获取推文?感谢
答案 0 :(得分:0)
我认为以下代码段应该回答您的问题(YYYY-MM-DD格式的日期)
Query query = new Query("#sad");
query.lang("en");
query.setSince("2006-01-01");
query.setUntil("2013-12-28");
QueryResult result = twitter.search(query);