我关注了来自HBC的快速入门,我设法从Twitter Stream获得了一些推文,指定了一些曲目条款,这里是代码:
/** 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 Stream?
我只是试图删除行“endpoint.trackTerms(terms);”,但这样做不起作用。
帮我!谢谢!
答案 0 :(得分:1)
它应该工作。我尝试了这个例子,并且“跟随”了我自己并收到了我在连接时发出的推文。
我怀疑您关注的用户在您使用流时没有任何活动,这就是您没有看到任何输出的原因 - 例如他们自己推特或有人回复他们的推特之一等......
follow
parameter文档概述了您将看到与关注用户相关的活动。
顺便说一句,在过滤器上指定followings
和trackTerms
时,它实际上是在说我这些用户的推文包含这些术语或。这就是为什么在指定trackTerms
时会看到输出的原因。这也适用于额外的locations
参数。