0

When executing a twitter query i get a 403 error, the error message is below, however my other queries work perfectly and are executed prior to this one, can anyone spot what may be wrong here:

TWITTER EXCEPTION: TwitterException{exceptionCode=[f3acd3ed-00581fa3], statusCode=403, retryAfter=0, rateLimitStatus=null, version=2.1.5-SNAPSHOT(build: d372a51b9b419cbd73d416474f4a855f3e889507)}

this occurs when i execute a search from my app, im not overdoing the limits as i can execute my other searches perfectly its just this one, any help would be appreciated, the code is listed below. im using a combination of Twitter4j and Processing with controlP5 to handle the input like the search.

void setup(){
...
             cp5.addTextfield("SEARCH")
             .setPosition(30,20)
             .setSize(100,20)
             .setFocus(true)
             .setColor(color(255,0,0))
             .setGroup(g2)
             ;
}

      public void SEARCH(String theText) {
        qm.srch = true;
        qm.theText = theText;
        qm.userSearch();
        qm.srch = false;
        // automatically receives results from controller input
        println("a textfield event for controller 'input' : "+theText);
      }

  void userSearch() {
    try {
      if (srch) {
        ConfigurationBuilder cb9 = new ConfigurationBuilder();
        cb9.setOAuthConsumerKey("XXXXXXXXXXXXXXXXXXXXXX");
        cb9.setOAuthConsumerSecret("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx");
        cb9.setOAuthAccessToken("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
        cb9.setOAuthAccessTokenSecret("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
        println("Connected");
        Twitter twitter = new TwitterFactory(cb9.build()).getInstance();
        Query srchh = new Query(theText2);

        srchh.setRpp(5);
        QueryResult srchhRes = twitter.search(srchh);
        ArrayList srchhTwe = (ArrayList) srchhRes.getTweets();
        for (int i = 0; i < srchhTwe.size(); i++) {

          Tweet t = (Tweet) srchhTwe.get(i);
          String user = t.getFromUser();
          GeoLocation l = t.getGeoLocation();
          String locNam = t.getLocation();
          String msg = t.getText();
          wholeTweetsL.add(msg);
          println("\nMessage: " + msg);
          println("\nLocation: " + locNam);
        }
      }
    }
    catch(TwitterException e) {
      println("TWITTER EXCEPTION: " + e);
    }
  }
4

1 回答 1

0

来自推特https://dev.twitter.com/docs/error-codes-responses

403 Forbidden 请求被理解,但已被拒绝或不允许访问。随附的错误消息将解释原因。当由于更新限制而拒绝请求时使用此代码。

于 2013-04-18T12:33:15.660 回答