3

I am using Twitter4j to access the streaming API. I am using follow, to get a stream related to a set of users. My problem basically boils down to this: Given a retweet (I have the retweet-id and the user-id of the retweet) in the stream, how can I find:

  1. the userID of the original tweet
  2. the tweetID of the original tweet

I don't suppose the API exposes this, does it?

harishankarv
  • 328
  • 2
  • 14

1 Answers1

5

If you want the userID and the tweetID of the original tweet you need to do inside onStatus:

@Override
public void onStatus(Status status) {
 if(status.isretweet()){
  Status originalTweet = status.getRetweetedStatus();
  long originaltweetid = originalTweet.getId();
  long originaluserid = originalTweet.getUser().getId();
    }
} 
FeanDoe
  • 1,608
  • 1
  • 18
  • 30
  • 1
    I have a follow up. What if the said retweet was a in fact a retweet of a retweet? `status.getRetweetedStatus()` returns the original tweet that was first tweeted right? I want to get the tweet in between. Is this possible? – harishankarv Jun 26 '15 at 19:55
  • status.getRetweetedStatus() returns the original first tweet, and you can't get the tweet in between, sorry. If A rt B and B rt C, and you capture A you'll get the status from C – FeanDoe Jun 30 '15 at 14:36