user2088363
user2088363

Reputation: 41

trying to stream tweets with twitter4j3.0.3

I am trying to stream tweets with twitter4j3.0.3 with scala but it gives me these errors. Here is my code:

   import twitter4j._
   import ch.qos.logback.core.status.StatusListener
   import twitter4j.conf.ConfigurationBuilder
   import ch.qos.logback.core.status

   object stream {



  def main(args: Array[String]) {
  val cb: ConfigurationBuilder = new ConfigurationBuilder
  cb.setDebugEnabled(true)
   .setOAuthConsumerKey("1")
   .setOAuthConsumerSecret("1")
   .setOAuthAccessToken("1")
   .setOAuthAccessTokenSecret("1")

 def simpleStatusListener:StatusListener =new StatusListener() {
  def addStatusEvent(status: Status) {println(x = status.getText)}


  def onStatus(status: Status) { println(x = status.getText) }
  def onDeletionNotice(statusDeletionNotice: StatusDeletionNotice) {}
  def onTrackLimitationNotice(numberOfLimitedStatuses: Int) {}
  def onException(ex: Exception) { ex.printStackTrace }
  def onScrubGeo(arg0: Long, arg1: Long) {}
  def onStallWarning(warning: StallWarning) {}

 }

 val twitterStream:TwitterStream= new TwitterStreamFactory(cb.build).getInstance()

 twitterStream.addListener(simpleStatusListener)
 twitterStream.sample()
 }
 }

and the error: overloaded method value addListener with alternatives: (twitter4j.RawStreamListener)Unit (twitter4j.SiteStreamsListener)Unit (twitter4j.StatusListener)Unit (twitter4j.UserStreamListener)Unit cannot be applied to (ch.qos.logback.core.status.StatusListener) twitterStream.addListener(simpleStatusListener) ^

Upvotes: 1

Views: 462

Answers (1)

Rotem Hermon
Rotem Hermon

Reputation: 2147

You're importing the wrong StatusListener interface. Instead of

import ch.qos.logback.core.status.StatusListener

You need

import twitter4j.StatusListener

Upvotes: 2

Related Questions