【问题标题】:Use Hbc Twitter Stream without specifying any track terms使用 Hbc Twitter Stream 而不指定任何跟踪条款
【发布时间】:2023-03-21 01:10:01
【问题描述】:

我遵循HBC快速入门,并设法从 Twitter 流中获取了一些推文,指定了一些跟踪条款,代码如下:

/** Declare the host you want to connect to, the endpoint, and authentication (basic auth or oauth) */
Hosts hosebirdHosts = new HttpHosts(Constants.STREAM_HOST);
StreamingEndpoint endpoint = new StatusesFilterEndpoint();
// Optional: set up some followings and track terms
List<Long> followings = Lists.newArrayList(1234L, 566788L);
List<String> terms = Lists.newArrayList("twitter", "api");
endpoint.followings(followings);
endpoint.trackTerms(terms);

是否可以在不指定任何跟踪条件的情况下使用 Hbc 获取 twitter 流? 我只是尝试删除行 "endpoint.trackTerms(terms);" 但这样做不起作用。
帮我!谢谢!

【问题讨论】:

    标签: java twitter twitter-streaming-api twitter-hbc


    【解决方案1】:

    它应该工作。我尝试了这个例子,并“关注”了自己,并收到了我在连接时发布的推文。

    我怀疑您关注的用户在您使用流媒体时没有任何活动,这就是您没有看到任何输出的原因 - 例如。他们自己发推文或有人回复他们的推文等......

    follow parameter 文档概述了您将看到的与关注用户相关的活动。

    顺便说一句,当在过滤器蒸汽上指定followingstrackTerms 时,它实际上是说让我从这些用户那里获得包含这些术语的推文。这就是为什么在指定 trackTerms 时会看到输出的原因。这也适用于附加的locations 参数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-18
      • 2011-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-14
      • 2019-09-22
      相关资源
      最近更新 更多