我正在尝试使用 scala 使用 twitter4j3.0.3 流式传输推文,但它给了我这些错误。这是我的代码:
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()
}
}
和错误:重载方法值 addListener 与替代品: (twitter4j.RawStreamListener)Unit (twitter4j.SiteStreamsListener)Unit (twitter4j.StatusListener)Unit (twitter4j.UserStreamListener)Unit 不能应用于 (ch.qos.logback.core.status. StatusListener) twitterStream.addListener(simpleStatusListener) ^