【问题标题】:Get Old Tweets on Twitter4j search在 Twitter4j 搜索中获取旧推文
【发布时间】:2015-11-20 22:52:45
【问题描述】:

我正在尝试在 Twitter 中搜索一个表达式,我的代码:

public static List<Status> searchQuery(Twitter twitter, String search)
        throws TwitterException, IOException {
    Query query = new Query(search);
    query.setCount(100);
    query.setSince("2015-05-25");
    QueryResult result;
    List<Status> tweets = null;
    do {
        System.out.println("Write to File ...");
        result = twitter.search(query);
        List<Status> newTweets = result.getTweets();
        if (tweets == null) {
            tweets = newTweets;
        } else {
            tweets.addAll(newTweets);
        }
        WriteToFile.writeTweetsToFile(newTweets);
    } while ((query = result.nextQuery()) != null);
    return tweets;
}

但它只是返回上个月的推文,当我使用 query.setUntil("2015-06-25"); 时没有返回。有什么问题?

【问题讨论】:

  • 您是否拥有正确的 API 密钥,以便您可以从很久以前进行此类查询?
  • @Makoto 我正在为上个月的推文生成 API 密钥并正常工作。
  • 你不能用普通的 API 密钥获取旧推文,你需要被推特白标
  • @FeanDoe 是如何被推特白标的?
  • Twitter API 有一些限制,看看这个库,它提供了获取旧推文的解决方案:github.com/Jefferson-Henrique/GetOldTweets

标签: java android twitter twitter4j


【解决方案1】:

我已经开发了一个代码来搜索没有这个时间限制的推文,你可以看看GitHub - GetOldTweets。它使用简单,您可以搜索最深的推文。

【讨论】:

  • 我在 GitHub 上看到了你的代码。我想通过他们的 id 获取推文,我该怎么做?
猜你喜欢
  • 2015-08-10
  • 2014-08-03
  • 2015-02-05
  • 1970-01-01
  • 1970-01-01
  • 2012-11-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多