尝试搜索twitter,Processing,Twitter4j,controlP5时出现403错误

时间:2013-04-18 11:46:36

标签: twitter processing twitter4j

当执行twitter查询时,我收到403错误,错误信息在下面,但是我的其他查询工作正常并且在此之前执行,有人可以发现这里可能出错的地方:

  

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

这种情况发生在我从我的应用程序执行搜索时,我没有超出限制,因为我可以完美地执行我的其他搜索只是这一个,任何帮助将不胜感激,代码如下所列。我使用Twitter4j和Processing与controlP5的组合来处理搜索等输入。

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);
    }
  }

1 个答案:

答案 0 :(得分:0)

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

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