Hi,

I wanna fetch PUBLIC tweets (not particular to any account) containing any
particular HASHTAG (#) (i.e "CocaCola" in my case) from twitter. I made an
APP on twitter to get the credentials, and then used Twitter Public
Streaming API.

Below is the piece of code.

{   val config = new twitter4j.conf.ConfigurationBuilder()
    .setOAuthConsumerKey("***")
               .setOAuthConsumerSecret("***")
    .setOAuthAccessToken("***")
    .setOAuthAccessTokenSecret("***")
    .build
    val twitter_auth = new TwitterFactory(config)
    val a = new twitter4j.auth.OAuthAuthorization(config)
    val atwitter : Option[twitter4j.auth.Authorization] = 
Some(twitter_auth.getInstance(a).getAuthorization())
    
    val sparkConf = new
SparkConf().setAppName("TwitterPublicStreaming").setMaster("local") 
      val ssc = new StreamingContext(sparkConf, Seconds(1))
     var filters: Seq[String]= "#CocaCola" ::Nil 
     val stream = TwitterUtils.createStream(ssc, atwitter,filters,
StorageLevel.MEMORY_AND_DISK_2)
     val data=stream.window(Seconds(1),Seconds(1))
     data.print()
     ssc.start()
     ssc.awaitTermination()
}

But most of the times it doesn't fetch tweets. it shows the Empty RDD as the
output.

Is there anything wrong? Can anyone points out the mistake? 
Thanks in Anticipation.




--
View this message in context: 
http://apache-spark-user-list.1001560.n3.nabble.com/Twitter-Streming-using-Twitter-Public-Streaming-API-and-Apache-Spark-tp24687.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@spark.apache.org
For additional commands, e-mail: user-h...@spark.apache.org

Reply via email to