自上周以来我一直坚持这个问题。由于某种原因,只有我的流被打印。这是我的一些代码:
twitterStream.user(new String[] {"username1", "username2"});
当我这样做时,我只能得到我的?我不知道为什么,我需要获取两个用户流,然后在
@Override
public void onStatus(Status status) {
// Get Data
}
出于某种原因,这只能获取我的流,例如关注者推文等。我如何获取用户名的 2 流?
最佳答案
它不起作用,因为 TwitterStream#user(String[])
接受关键字进行跟踪,但不接受用户名。 user stream仅流式传输当前经过身份验证的用户的事件。
您必须启动另一个用户流才能获取第二个用户的事件。
这就是 the documentation不得不说的是多用户流:
Minimize the number of connections your application makes to User Streams. Each Twitter account is limited to only a few simultaneous User Streams connections per OAuth application, regardless of IP. Once the per-application limit is exceeded, the oldest connection will be terminated. An account logging in from too many instances of the same OAuth application will cycle connections as the application instances reconnect and disconnect each other.
请注意,使用 site stream 可能会更好如果您想代表更多用户进行连接,但目前似乎处于有限的 beta 测试阶段。
编辑:
track 参数也与屏幕名称相匹配,请参阅 track
parameter documentation了解更多信息。
关于java - Twitter4j 中的多个用户流?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19369347/