braden.groom
braden.groom

Reputation: 325

How do I get Twitter4J to stream posts with a certain hashtag?

When I search for a given hashtag, I get the results for recent tweets containing that hashtag. This is what I want to stream, So if any new tweets with this hashtag are made I will know.

Upvotes: 3

Views: 4124

Answers (1)

Bart Vangeneugden
Bart Vangeneugden

Reputation: 3446

Twitter twitter = new TwitterFactory().getInstance();
try {
    QueryResult result = twitter.search(new Query("#myhashtag"));
} catch (TwitterException te) {
    te.printStackTrace();
}

Source

You may need to escape the # symbol

Upvotes: 4

Related Questions