[英]Unexpected response code 429 when using Volley in Android?
我可以在幾分鍾內從 URL 獲取 JSON 信息,但最終它會給我“意外響應代碼 429”。 鏈接來自 Steam,我想知道這是 Volley 還是 Steam 的問題? 這是我當前的實現,因為我的代碼中可能遺漏了一些東西。
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);
429響應碼表示
Too Many Requests
The user has sent too many requests in a given amount of time ("rate limiting").
您嘗試點擊的 api 可能僅限於您在一天或一定時間內可以進行的點擊次數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.