Hi, I am new to twitter API, my goal is to use filtered stream API to stream tweets with some keywords.
I am using twitter4J library 4.0.7 which is latest version . Getting below error while trying to stream tweets. Why its forcing me to use V2 version API, it seems twitter4J library is connecting to old API,
How to fix this ?

403:The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits (https://support.twitter.com/articles/15364-about-twitter-limits-update-api-dm-and-following).

\n\n\nError 403 Please use V2 filtered and sample volume stream as alternatives

HTTP ERROR: 403

Problem accessing '/1.1/statuses/sample.json?stall_warnings=true'. Reason:

    
Please use V2 filtered and sample volume stream as alternatives

Relevant discussions can be found on the Internet at:
http://www.google.co.jp/search?q=4d13a6ae or
http://www.google.co.jp/search?q=d6626d63
TwitterException{exceptionCode=[4d13a6ae-d6626d63], statusCode=403, message=null, code=-1, retryAfter=-1, rateLimitStatus=null, version=4.0.7}
at twitter4j.HttpClientImpl.handleRequest(HttpClientImpl.java:170)
at twitter4j.HttpClientBase.request(HttpClientBase.java:57)
at twitter4j.HttpClientBase.get(HttpClientBase.java:75)
at twitter4j.TwitterStreamImpl.getSampleStream(TwitterStreamImpl.java:201)
at twitter4j.TwitterStreamImpl$4.getStream(TwitterStreamImpl.java:170)
at twitter4j.TwitterStreamImpl$TwitterStreamConsumer.run(TwitterStreamImpl.java:570)

This only supports v1.1 API.

You probably want GitHub - takke/twitter4j-v2: a simple wrapper for Twitter API v2 that is designed to be used with Twitter4J

1 Like

I am facing the same error but looks like this wrapper does not support filtered stream. Any other way to use API V2 with twitter4J?

1 Like

As of now twitter4j-v2 also doesn’t support streaming, may be the contributor will think and do it later or may me I will add this functionality later when have time but can’t commit on this.

Also can you try this library, I guess it has filtered data stream
GitHub - twitterdev/twitter-api-java-sdk: A Java SDK for the Twitter API

1 Like

Has anybody found a working alternative solution to this problem?

I think this is a working example for v2 in java:

That won’t work with Spring Boot.