[英]Twitter4j TwitterStream filter() not working to update parameters
I have a TwitterStream
object: 我有一个TwitterStream
对象:
static TwitterStream twitterStream = new TwitterStreamFactory().getInstance();
which I add a listener to, and some user ids to track (the user ids are correct, and this part works): 我在其中添加了一个侦听器,并跟踪了一些用户ID(用户ID正确,并且这部分有效):
twitterStream.addListener(listener);
twitterStream.filter(new FilterQuery(followArray));
The problem, is that inside the listener, in onStatus(Status status)
I want to add a user to track. 问题是,在侦听器内部,我要添加要跟踪的onStatus(Status status)
。 I've tried this two ways, first by simply doing 我已经尝试过两种方法,首先是简单地
twitterStream.filter(new FilterQuery(newArray));
where this newArray
is the old one plus the new user id, and I've also tried calling 这里的newArray
是旧的,再加上新的用户ID,我也尝试调用
twitterStream.cleanUp();
before filter()
. 在filter()
之前。 In both cases, the code appears to run, but then when I tweet from one of the followed accounts, I get the message 在这两种情况下,代码似乎都可以运行,但是当我从以下一个帐户发送推文时,我得到了消息
[Tue May 13 15:30:08 EDT 2014]Establishing connection. [2014年5月13日星期二15:30:08 EDT]建立连接。
and then the program terminates. 然后程序终止。
I can provide my full code if necessary, but any debugging help would be appreciated. 如果需要,我可以提供完整的代码,但是任何调试帮助都将不胜感激。
Sometimes you have to sleep the main thread for a period of time. 有时您必须将主线程休眠一段时间。 Check whether you have the following code: 检查您是否具有以下代码:
Thread.sleep(400000)
after 后
twitterStream.filter(new FilterQuery(newArray));
and before 和之前
twitterStream.cleanUp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.