2012-02-17 61 views
0

我正在尝试做一个简单的Twitter feed分析,我只是简单地请求twitter上的用户的json feed并将其解析为一个对象。在Android上抓取Twitter Feed - 设备上的费率限制超出限制?

问题是,这在模拟器上工作完美,但是当部署在真实设备上时,我得到一个400错误的请求响应,它似乎超过了403的速率限制,但是这是第一个请求发送的速率,速率如何限制被超过?

 public ArrayList<Tweet> getTweets() { 

     ArrayList<Tweet> tweets = 
      new ArrayList<Tweet>(); 

     HttpClient client = new DefaultHttpClient(); 
     HttpGet get = new HttpGet(twitterUrl); 

     ResponseHandler<String> responseHandler = 
      new BasicResponseHandler(); 

     String responseBody = null; 
     try { 
     responseBody = client.execute(get, responseHandler); 
     } catch(Exception ex) { 
     ex.printStackTrace(); 
     timeOut = true; 
     } 

     JSONObject jsonObject = null; 
    JSONArray arr = null; 
    try { 
     arr = new JSONArray(responseBody); 
    } catch (JSONException e1) { 
     e1.printStackTrace(); 
     timeOut = true; 
    } 

     for (int i = 0; i < arr.length(); i++) { 
      try { 
       jsonObject = arr.getJSONObject(i); 
      } catch (JSONException e1) { 
       e1.printStackTrace(); 
       timeOut = false; 
      } 
      Tweet tweet = null; 
      try { 
       tweet = new Tweet(
         jsonObject.getJSONObject("user").getString("name"), 
         jsonObject.getString("text"), 
         jsonObject.getJSONObject("user").getString("profile_image_url"), 
         twitterHumanFriendlyDate(jsonObject.getString("created_at")) 
       ); 
      } catch (JSONException e) { 
       e.printStackTrace(); 
       timeOut = true; 
      } 
      tweets.add(tweet); 
     } 

     return tweets; 
    } 

这里是解析饲料的例子:

Example Twitter JSON feed

我失去的东西我必须做的就是它在设备上工作?我没有注册Titter或任何东西,我是否必须得到某种类似于谷歌地图键或类似的Twiiter键?

编辑:它实际上通过Wi-Fi工作,但不通过移动数据连接,他们是否反对保护移动连接的速率限制?

回答

0

这是我的运营商的网络问题!抱歉!