我正在使用 twitter4j 使用 max_id 下载旧推文,如下所示:
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
String emotion = "#sad OR #happy OR #angry OR #anxious OR #fear OR #surprised";
Query query = new Query(emotion);
query.setMaxId(576017086843088896L); // start downloading tweets older than this tweet
query.setCount(100);
QueryResult queryResult = twitter.search(query); // returns zero tweets
我尝试根据之前下载的有效状态 ID 设置各种 MaxId。但它返回的推文为零。 如果我不设置 MaxId,它工作正常并返回最近的推文。 知道出了什么问题吗?
更新:我也尝试使用以下配置(删除了 maxId 配置)。这也导致推文数量为零。
query.since("2015-01-01");
query.until("2015-03-11");
最佳答案
twitter.search(查询)
这将仅获取过去 7 天的推文。
在此时间之前您无法进行搜索。您可能需要查看私有(private) API,例如 https://gnip.com/sources/twitter/historical/
关于java - Twitter4j API : setMaxId() not working properly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29173225/