Is it possible to get a list of tweets that reply to a tweet (or to its replies) using twitter4j? The twitter website and Android app have this feature.
See Question&Answers more detail:osIs it possible to get a list of tweets that reply to a tweet (or to its replies) using twitter4j? The twitter website and Android app have this feature.
See Question&Answers more detail:osHere's a code I'm using in welshare
The first part gets all the tweets that twitter is displaying below the tweet, when it is opened. The rest takes care of conversations, in case the tweet is a reply to some other tweet.
RelatedResults results = t.getRelatedResults(tweetId);
List<Status> conversations = results.getTweetsWithConversation();
/////////
Status originalStatus = t.showStatus(tweetId);
if (conversations.isEmpty()) {
conversations = results.getTweetsWithReply();
}
if (conversations.isEmpty()) {
conversations = new ArrayList<Status>();
Status status = originalStatus;
while (status.getInReplyToStatusId() > 0) {
status = t.showStatus(status.getInReplyToStatusId());
conversations.add(status);
}
}
// show the current message in the conversation, if there's such
if (!conversations.isEmpty()) {
conversations.add(originalStatus);
}
EDIT: This wont work anymore as Twitter API v 1 is now not in use