I am trying to do some analysis on Tweets using Twitter Streaming API.
I first wanted to print the Status messages from stream, and start from there.
My code is shown below:
public static void main(String[] args) {
SparkConf conf = new SparkConf().setAppName("TwitterStreamPrinter").setMaster("local");
Configuration twitterConf = new ConfigurationBuilder()
.setOAuthConsumerKey(consumerKey)
.setOAuthConsumerSecret(consumerSecret)
.setOAuthAccessToken(accessToken)
.setOAuthAccessTokenSecret(accessTokenSecret).build();
OAuth2Authorization auth = new OAuth2Authorization(twitterConf);
JavaReceiverInputDStream<Status> twitterStream = TwitterUtils.createStream(ssc, auth);
JavaDStream<String> statuses = twitterStream.map(new Function<Status, String>() {
public String call(Status status) throws Exception {
retu status.getText();
}
});
statuses.print();
It does not print out anything other than Spark logs. I initially thought that this was because of authorization, so I tried all kinds of different ways to pass the authorization, but maybe it's not the authorization.
I looked at every example I could find from the web (although there's not many), and this code looks like a standard code to get Twitter statuses, but why is it not printing anything? I also tried System.out.println, but it didn't work.
