位置跟踪项必须以逗号分隔的纬度/长度Twitter4J Scala对给出

时间:2018-01-04 10:06:05

标签: scala twitter twitter4j

我正在尝试按用户位置过滤推文。我在Scala中使用Twitter4J。但每次我收到错误

Parameter not accepted with the role. 406:Returned by the Search API when an invalid format is specified in the request.
Returned by the Streaming API when one or more of the parameters are not suitable for the resource. The track parameter, for example, would throw this error if:
The track keyword is too long or too short.
The bounding box specified is invalid.
No predicates defined for filtered resource, for example, neither track nor follow parameter defined.
Follow userid cannot be read.
Location track items must be given as pairs of comma separated lat/longs: [Ljava.lang.String;@48d1de0f

这是我的代码:

def main(args: Array[String]): Unit = {    
    val twitterStream = TwitterStreamFilters.configureTwitterStream()
        val counter = new Counter
        twitterStream.addListener(counter)
        TwitterStreamFilters.filterTwitterStreamByLocation(twitterStream, Array(-122.75,36.8,-121.75,37.8))
        TwitterStreamFilters.closeTwitterStream(twitterStream)
    }

我从this link获取旧金山的位置。 那么为什么这个Twitter流不起作用呢?我很感激任何建议。

地点的方法:

  def filterTwitterStreamByLocation(twitterStream: TwitterStream, coordinates: Array[Double]) = {
    twitterStream.filter(new FilterQuery().locations(coordinates))
  }

1 个答案:

答案 0 :(得分:2)

按照上面的评论,这应该可以解决您的问题:

<ul>