Залп не отвечает на API - PullRequest
       13

Залп не отвечает на API

0 голосов
/ 17 апреля 2019

Я пытаюсь получить Instagram API для идентификатора пользователя, но когда я пытаюсь запустить его через библиотеку залпа в Android, это выдает мне эту ошибку

E / Volley: [4914] BasicNetwork.performRequest: неожиданный код ответа 403 для https://www.instagram.com/gmp009/?__a=1

В моем браузере этот API работает нормально, выдавая JSON в ответ, но я не знаю, почему я получаю эту ошибку залпом

Я пытаюсь искать в интернете, но не вижу ничего, что могло бы мне помочь.

 public void firstServiceCall(String url) {

        JsonObjectRequest jsonObjReq = new JsonObjectRequest(
                Request.Method.GET, url, null,
                new Response.Listener<JSONObject>() {

              @Override
              public void onResponse(JSONObject response) {

                    try {
                            JSONObject user = response.getJSONObject("graphql");
                            JSONObject newUser = user.getJSONObject("user");

                            final String profilePicture = newUser.getString("id");
                            final String imageURL = newUser.getString("profile_pic_url");
                            Log.v("FUCK1", profilePicture.toString());

                            //finish();
                            //https://i.instagram.com/api/v1/users/30692469/info/    

                            String newURL = "https://i.instagram.com/api/v1/users/";
                            String NewURL3 = profilePicture;
                            String newURL2 = "/info/";

                            String REALURL = newURL + NewURL3 + newURL2;

                            secondServiceCall(profilePicture,REALURL);           
                        }

                        catch (JSONException e) {
                            e.printStackTrace();
                        }

                        //suppose the membershipid comes under main json with key "membershipid"
                        // on the response of first service ... call to the second service ... and continue so on... if required
                    }
                }, new Response.ErrorListener() {

            public void onErrorResponse(VolleyError error) {

                // As of f605da3 the following should work
                NetworkResponse response = error.networkResponse;
                if (error instanceof ServerError && response != null) {
                    try {
                        String res = new String(response.data,
                                HttpHeaderParser.parseCharset(response.headers, "utf-8"));
                        // Now you can use any deserializer to make sense of data
                        JSONObject obj = new JSONObject(res);
                    } catch (UnsupportedEncodingException e1) {
                        // Couldn't properly decode data to string
                        e1.printStackTrace();
                    } catch (JSONException e2) {
                        // returned data is not JSONObject?
                        e2.printStackTrace();
                    }
                }
            }
        });
        Volley.newRequestQueue(getApplicationContext()).add(jsonObjReq);
    }
...