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

标签 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);

最佳答案

429响应码表示

Too Many Requests

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

您尝试点击的 api 可能会限制您在一天或特定时间内可以点击的次数。

关于java - 在 Android 中使用 Volley 时意外的响应代码 429?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36977284/

相关文章:

java - 是否可以使用 Timer 为 JButton 创建淡入淡出效果?

java - 有没有更好的方法让我的计算机对手生成 (3 > 随机长度 <= 7) 的单词?

android - 如何进行大于或小于 "Safe Casts"的比较

Iphone 能够在多任务环境中自动暂停和恢复文件下载

javascript - 如何在 Meteor 中记录出站 HTTP 请求?

java - 受密码保护的 PDF Jaspersoft

java - 导入包但出现访问限制类型错误

android - SQLite 查询返回空

android - 如何在 Android 模拟器中模拟陀螺仪

java - 似乎无法让从我的 Android 应用程序发送的 http 获取参数显示在我的 PHP 页面上