0

我正在尝试使用特殊主题标签流式传输推文,但似乎我无法使用twitterstreamfactor. 我不断收到一条错误消息:type twitterstreamfactory not found

这是我的代码:

import java.lang.Object
import twitter4j._
import ch.qos.logback.core.status.StatusListener
import twitter4j.TwitterFactory
import twitter4j.conf.ConfigurationBuilder
import collection.JavaConversions._
//import twitter4j.TwitterStreamFactory
import twitter4j.Query


object stream {

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

def simpleStatusListener = new StatusListener() {
  def onStatus(status: Status) { println(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 = new TwitterStreamFactory(cb.build).getInstance()
twitterStream.addListener(simpleStatusListener)
twitterStream.filter(new FilterQuery("#happy"))
Thread.sleep(2000)
twitterStream.cleanUp
twitterStream.shutdown
}

}

我不知道我做错了什么,但我不断收到错误not found:type twitterstreafactory
如果有人可以帮助我,我将不胜感激。

4

0 回答 0