Closed consal closed 2 years ago
Hello @consal , honestly I never tested this use case before, if it is working from CLI but not in the library, that's probably a bug. I'm in travel right now but I'll try to check in the next following days :)
I didn't find anything in the code who can explain that. Just created a post on Twitter Forum there : https://twittercommunity.com/t/filtered-stream-without-rules/164922
The sample stream is a different endpoint, and returns random 1% of all public tweets, while the filter stream returns tweets that match the rules only. If there are no rules or you delete rules while the stream is open, I think it just sends nothing.
Ohhh well seen @igorbrigadir ! @consal you were looking for another method, which is startSampledStream
no ?
See : https://github.com/redouane59/twittered/blob/f6c6fea028ead7086454a3329acacdd6bd485601/src/main/java/io/github/redouane59/twitter/ITwitterClientV2.java#L259
Oh, nice! Let me try the sampled stream and I'll let you know if it works!
Unfortunately the Sampled stream doesn't seem to work, the code:
TwitterClient twitterClient = new TwitterClient(TwitterCredentials.builder()
.bearerToken(bearerToken).build());
Future<Response> future = twitterClient.startSampledStream((Tweet tweet) -> {
logger.info("from:@" + tweet.getUser().getName() + " : " + tweet.getText());
});
The stream doesn't return anything, it immediately returns. Adding future.get()
doesn't change anything.
The same code changed to startFilteredStream
with adding some filters works.
Juste used your code on my side and it is correctly working :
Are you sure you are outside a unit test ? You need to run it from a Main class :)
Today I reran exactly the same code and it's working 😅 No idea what I was doing wrong yesterday. Anyway, thanks so much for your help!
Hello! Is it possible to use
startFilteredStream
without setting filters before (withaddFilteredStreamRule
)? For me, if there are no filters, there is no response at all. In CLI, trying with curl and no filters, it returns plenty of tweets.curl -X GET -H "Authorization: Bearer $BEARER_TOKEN" "https://api.twitter.com/2/tweets/sample/stream"