开发者

TwitterException {statusCode=403, retryAfter=0, rateLimitStatus=null}

I have recently noticed that I keep getting a 403 error while doing twitter search. My application was working until couple of days back when i noticed the error.

I checked with Twitter & they say my IP is not blocked, I am also within the rate limit = about 60 search requests/per hour.

Here's how i was initializing the Twitter object -

private static Twitter TWITTER_CLIENT = new TwitterFactory().getInstance();

After i noticed the error, i tried the following & still no success -

p开发者_JS百科rivate static Twitter TWITTER_CLIENT = new TwitterFactory().getInstance("user", "password");

Here's how i am searching -

TWITTER_CLIENT.search(new Query("#keyword1 OR #keyword2"));

I tried this URL (curl http://search.twitter.com/search.json?q=ipad) from my server & it works alright.

Following is the exception. I am on java6 + Twitter4j v2.1.2. Would really appreciate any help. Thanks.

TwitterException{statusCode=403, retryAfter=0, rateLimitStatus=null}
    at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:301)
    at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:68)
    at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:82)
    at twitter4j.Twitter.search(Twitter.java:193)


Most likely the reason is basic auth shutdown by Twitter (aka OAuthcalypse):

Basic Auth Shutdown

You need to switch to using OAuth.


Recently i got the same error while executing similar code. To fix it, please go to

  1. https://apps.twitter.com/app/your_app_id
  2. Click on Keys and access token
  3. In Access Level, click modify app permission and choose the 3rd option: Read, Write and Access direct messages
  4. Click on update. ( Note: you might have to add your mobile no and verify with otp to get this access if you dont have your no added in twitter)
  5. Regenerate both Consumer key & secretand Access token & secret using the clickable button
  6. Us e the new keys in your program

And you are done! Your program will start working.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜