2016-05-02 66 views
1

我能夠從URL獲取JSON信息幾分鐘,但最終它會給我「意外的響應代碼429」。鏈接來自Steam,我想知道這是Volley還是Steam的問題?這是我目前的實現,因爲它可能會從我的代碼中丟失一些東西。在Android中使用Volley時出現意外的響應代碼429?

RequestQueue queue = Volley.newRequestQueue(this); 

      // Request a string response from the provided URL. 
      JsonObjectRequest stringRequest = new JsonObjectRequest(Request.Method.GET, retrievalURL, null, 
        new Response.Listener<JSONObject>() { 
         @Override 
         public void onResponse(JSONObject response) { 
          try { 
           int indexOfWear = listOfWears.indexOf(wear); 
           Map<String, String> itemInList = listWearsAndPrices.get(indexOfWear); 
           if (response.getBoolean("success")) { 
            itemInList.put("Price", response.getString("lowest_price")); 
           } else { 
            // If price is not possible 
            itemInList.put("Price", "Item Unavailable"); 
            Log.e("tag", "Item unavailable unreached"); 
           } 
           // Update view 
           adapter.notifyDataSetChanged(); 
          } catch (JSONException e) { 
           e.printStackTrace(); 
          } 
         } 


        }, new Response.ErrorListener() { 
       @Override 
       public void onErrorResponse(VolleyError error) { 
        /** 
        * TODO 
        * CHECK FOR INTERNET CONNECTION 
        */ 
        int indexOfWear = listOfWears.indexOf(wear); 
        Map<String, String> itemInList = listWearsAndPrices.get(indexOfWear); 
        itemInList.put("Price", "Item Unavailable"); 
        adapter.notifyDataSetChanged(); 
       } 
      }); 
      // Add the request to the RequestQueue. 
      queue.add(stringRequest); 
+0

您是否在點擊服務前檢查了互聯網連接? –

回答

1

429響應代碼意味着

Too Many Requests 

The user has sent too many requests in a given amount of time ("rate limiting"). 

也許API,您正在試圖擊中僅限於點擊次數,你可以在一天或一定的時間做。

相關問題