Twitter4j异常与跟踪和地理定位



我正在尝试获取tweet,其中包含单词"python"或我所在城市周围的tweet

这是我的代码:

    StatusListener listener = new MyStatusListener(twitter);
    twitterStream.addListener(listener);
    FilterQuery query = new FilterQuery();
    String[] arr = { "python" };
    double lat = 18.5203;
    double lon = 73.8567;
    double[][] locations = { { lat, lon } }; // for Pune city
    query.track(arr);
    query.locations(locations);
    twitterStream.filter(query);

当我运行这个,我得到以下异常:

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;@405ef8c2
[Thu Jun 26 19:06:58 GMT+05:30 2014]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;@405ef8c2

我得到同样的消息成对。如果移除位置条件,代码就能正常工作。我不确定这里的问题是什么。有人能帮忙吗?

是我的错。我假设如果我不提供一对,twitter将假设一个半径(就像它在web UI上做的那样-靠近一个城市)。但我想你必须提供一个边界框。给出一个边界框对我来说很有效

最新更新