2012-02-17 50 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

這是我的運營商的網絡問題!抱歉!