在Android中使用Volley时出现意外的响应代码429?

时间:2016-05-02 07:35:25

标签: java android http android-volley

我能够从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);

1 个答案:

答案 0 :(得分:1)

429响应代码意味着

Too Many Requests

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

你试图击中的可能性仅限于你可以在一天或一定时间内完成的点击次数。