Server returned HTTP response code: 403 for URL


#1

I have been collecting account statistics of some users for awhile using twitter4j. My app was working fine, but suddenly since last couple of days it has stopped working and produces the following error message. SSL connection is enabled in the program. - TIA, Shankar

Server returned HTTP response code: 403 for URL: http://api.twitter.com/1.1/users/show.json?screen_name=JRPierro&include_entities=1&include_rts=1
Relevant discussions can be found on the Internet at:
http://www.google.co.jp/search?q=bb0a5eb5 or
http://www.google.co.jp/search?q=3115c744
TwitterException{exceptionCode=[bb0a5eb5-3115c744 5147af80-f1a31d04 5147af80-f1a31d02], statusCode=-1, message=null, code=-1, retryAfter=-1, rateLimitStatus=null, version=3.0.3}
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:192)
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:61)
at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:89)
at twitter4j.TwitterImpl.get(TwitterImpl.java:1817)
at twitter4j.TwitterImpl.showUser(TwitterImpl.java:833)
at twitter.ids.AccountStatistics.getFriends(AccountStatistics.java:95)
at twitter.ids.AccountStatistics.main(AccountStatistics.java:76)
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://api.twitter.com/1.1/users/show.json?screen_name=JRPierro&include_entities=1&include_rts=1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at twitter4j.internal.http.HttpResponseImpl.(HttpResponseImpl.java:36)
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:156)
… 6 more
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://api.twitter.com/1.1/users/show.json?screen_name=JRPierro&include_entities=1&include_rts=1
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at twitter4j.internal.http.HttpResponseImpl.(HttpResponseImpl.java:34)
… 7 more

429:Returned in API v1.1 when a request cannot be served due to the application’s rate limit having been exhausted for the resource. See Rate Limiting in API v1.1.(https://dev.twitter.com/docs/rate-limiting/1.1)
message - Rate limit exceeded
code - 88

Relevant discussions can be found on the Internet at:
http://www.google.co.jp/search?q=bb0a5eb5 or
http://www.google.co.jp/search?q=3115c735
TwitterException{exceptionCode=[bb0a5eb5-3115c735], statusCode=429, message=Rate limit exceeded, code=88, retryAfter=-1, rateLimitStatus=RateLimitStatusJSONImpl{remaining=0, limit=180, resetTimeInSeconds=1389979851, secondsUntilReset=638}, version=3.0.3}
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:177)
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:61)
at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:89)

at twitter4j.TwitterImpl.get(TwitterImpl.java:1817)
at twitter4j.TwitterImpl.showUser(TwitterImpl.java:833)

#2

Since Jan 14th, 2014, api.twitter.com only accept SSL connections, you need to do HTTPS requests. Please, check the announcement here: https://dev.twitter.com/discussions/24239