1

我使用 Twitter4J 搜索推文。我使用了查询类。我用我想要的短语创建了自己的推文来搜索尝试。但是当我搜索它时,它似乎没有看到我的推文。那么我怎样才能确定我是否可以搜索推文呢?

我的代码是:

    Twitter twitter = new TwitterFactory(getConfig().build()).getInstance();
    Query query = new Query(URLEncoder.encode("#MatthewPogi"));
    QueryResult qr = twitter.search(query);
    List<Status> statuses = qr.getTweets();
    for(Status status: statuses) {
        System.out.println(status.getId() + " " + status.getText() + " " + status.getSource());
4

2 回答 2

1

尝试这个 :

*Query query = new Query("#MatthewPogi");
            QueryResult result;
            do {
                result = twitter.search(query);
                List<Status> tweets = result.getTweets();
                for (Status tweet : tweets) {
                    Date createdAt = tweet.getCreatedAt();
                    System.out.println("@" + tweet.getUser().getScreenName() + " - " + tweet.getUser().getCreatedAt() + " - " +tweet.getText() + " - " +tweet.getUser().getLocation());
                }
            } while ((query = result.nextQuery()) != null);*
于 2014-01-14T18:24:46.760 回答
0
Query query = new Query("ekkada");
QueryResult result;
do {
    result = twitter.search(query);
    List<Status> tweets = result.getTweets();
    int i = 0;
    for (Status tweet : tweets) {
        fw.write("#" + (i++) + "  " + tweet.getCreatedAt() + " @" + tweet.getUser().getScreenName() + " - " + tweet.getText());
        fw.write("\n");
    }
} while ((query = result.nextQuery()) != null);
于 2016-06-11T21:14:13.583 回答