You can use streaming API to get the recent tweets by a given set of keywords. In your case you have only one keyword which is a hashtag, right? I posted a brief sample code to search tweets by a keyword with Streaming API. You can use both Streaming and Search API for different purposes. Mostly you can use Search API for the hostorical tweets up to a limited time. It allows you to give a date interval. However, you can use Streamin API to catch the recently posted tweets as a tweet stream that contains the keywords that you give.
Example straming code below:
private static void GetTweetStreamForKeywords()
{
TwitterStream twitterStream = new TwitterStreamFactory(config).getInstance();
StatusListener statusListener = new StatusListener() {
@Override
public void onStatus(Status status) {
// The main section that you get the tweet. You can access it by status object.
// You can save it in a database table.
}
@Override
public void onDeletionNotice(StatusDeletionNotice sdn) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void onTrackLimitationNotice(int i) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void onScrubGeo(long l, long l1) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void onStallWarning(StallWarning sw) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void onException(Exception ex) {
logWriter.WriteErrorLog(ex, "onException()");
}
};
FilterQuery fq = new FilterQuery();
String keywords[] = {"sport", "politics", "health"};
fq.track(keywords);
twitterStream.addListener(statusListener);
twitterStream.filter(fq);
}