简体   繁体   中英

Multiple User Streams in Twitter4j?

I am have been stuck on this since last week. For some reason, only my stream is Printed. Here is some of my Code:

twitterStream.user(new String[] {"username1", "username2"});

When i do this, i only gets mine? I am not sure why, i needed to get both users streams, then in the

@Override
public void onStatus(Status status) {
    // Get Data
}

For some reason, this only gets my stream, like followers tweets etc. How do i get username's 2 stream?

It's not working because TwitterStream#user(String[]) accepts keywords to track and not user names. The user stream only streams events for the currently authenticated user.

You will have to start another user stream to get events for a second user.

This is what the documentation has to say about multiple user streams:

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.

Note that it might be better to use a site stream if you want to connect on behalf of more users, however it appears to be in limited beta-testing presently.

EDIT:

The track parameter is also matched against the screen name, see the track parameter documentation for more information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM