Getting original tweet-id and user-id from retweet-id

2.1k views Asked by At

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?

1

There are 1 answers

2
FeanDoe On BEST ANSWER

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();
    }
}