2

我想在 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

那么,我如何通过将日期作为参数来获取推文?谢谢

4

1 回答 1

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);

于 2014-01-28T15:42:25.053 回答