【问题标题】:Twitter4j Exception with track and geolocation带有跟踪和地理位置的 Twitter4j 异常
【发布时间】:2014-06-26 22:09:38
【问题描述】:

我正在尝试获取包含“python”一词或我所在城市周围的推文

这是我的代码:

    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 twitter4j


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-29
      相关资源
      最近更新 更多