2012-02-17 4 views
0

私はTwitterフィードの単純な解析をしようとしています。私はTwitterのユーザーのjsonフィードを要求し、それをオブジェクトに解析するだけです。AndroidでTwitterフィードを取得する - デバイスのレート制限を超えましたか?

この問題は、エミュレータでは完全に機能しますが、実際のデバイスにデプロイした場合、403の制限を超過しているように見える400の不正なリクエスト応答が表示されますが、限界を超えていますか?ここで

 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や何かに登録していない、私はGoogleマップのキーに類似したいくつかの種類のTwiiterキーを取得する必要がありますか?

EDIT:実際にはWi-Fiでは動作しますが、モバイルデータ接続では動作しませんが、モバイル接続のレート制限から保護するにはどうしますか?

答えて

0

これは通信事業者のネットワーク上の問題でした。ごめんなさい!

関連する問題