0

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.

Alex Bitek
  • 6,529
  • 5
  • 47
  • 77
Charlie-Blake
  • 10,832
  • 13
  • 55
  • 90

1 Answers1

3

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;
    }
  }
}
YAMAMOTO Yusuke
  • 732
  • 4
  • 5
  • So, if I understood properly, I cannot get all my replies via Streaming? Is there any way to fetch replies posted after a certain date, via streaming or regular API fetching? – Charlie-Blake Nov 28 '12 at 15:23
  • Streaming doesn't return data from previous dates, it is an online-process. You can use search api for getting tweets up to last 10 days. I am not sure if you can query for your replies, but you can filter out the results again as Yusuke suggested. – cubbuk Jan 04 '13 at 08:28