简体   繁体   中英

Twitter4j how to get tweets from certain time

Query query = new Query("Apple");
     query.lang("en");
     query.setCount(100);
     query.setSince("2018-12-03");
     query.setUntil("2018-12-04");
     QueryResult result = twitter.search(query);
     SentiWordNetDemoCode sentiwordnet = new SentiWordNetDemoCode();
     for (Status tweet : result.getTweets()){
        System.out.println(tweet.getCreatedAt());
     }

When testing this, all the tweets are from 7:59 SRET. Is there any way to get a tweet from a time other than this?

According to the API reference on twitter, there are some restrictions to the query. There is no (more) since parameter, only a since_id which takes a status id. Then you can only search in the last 7 days. So the until field should not be older than that.

https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM