0
votes

I need to stream all public tweets which contain a certain hashtag AND replies to a certain account (which I own) and store them in a database. However, I can't get Twitter4j to do this for me.

Is there something I'm missing? I've only been able to stream my timeline.

1

1 Answers

3
votes

You cannot specify criteria like "replies to a certain account" with filter stream. However, it is possible to detect if a tweet is a reply to a certain account by using Status#getUserMentionEntites(). The code will be like this:

public void onStatus(Status status){
  for(UserMentionEntity mention : status.getUserMentionEntities()){
    if(mention.getScreenName().equals("yusuke")){
      // do whatever you want
      break;
    }
  }
}