简体   繁体   中英

HTTP response with java class is different from the response in the browser android?

i have problem with my rest. I use Volley library, but the results different from the response in the browser android ?

this is, ther URL =

https://assac.com/profilepicture?app_key=bpHANRATGW35hkHNMJA9ssMOnLog9l7l3IxXDGiv&session_key=LSDK4ARF0w8flNc8GCj8mvvKdctKnN68FKSKlKplhyAClNK2&page=1&limit=10

and this format in java

String url = Variabel.URL_PHOTO_PROFILE + "?app_key=" + URLEncoder.encode(Variabel.app_key) + "&session_key=" + URLEncoder.encode(session_key)
                + "&page=" + String.valueOf(Variabel.page) + "&limit="
                + Variabel.LIMIT_DATA;

full code :

private void getNewAllPhotoUserFromServer() {

        String url = Variabel.URL_PHOTO_PROFILE + "?app_key=" + Variabel.app_key + "&session_key=" + session_key
                + "&page=" + String.valueOf(Variabel.page) + "&limit="
                + Variabel.LIMIT_DATA;
        Log.v("new", url);
        queue_get_new_all_photo_user = Volley.newRequestQueue(getActivity());
        sr_get_all_new_photo_user = new StringRequest(Request.Method.GET, url,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {

                        DrawDataAllPhotoUser(response);
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {

                if (error instanceof NetworkError) {
                    messageRespone("Koneksi bermasalah");
                } else if (error instanceof ServerError) {
                    messageRespone("Server Error");
                } else if (error instanceof AuthFailureError) {
                    messageRespone("Koneksi Timeout");
                } else if (error instanceof ParseError) {
                    messageRespone("Ada masalah dalam mengambil data");
                } else if (error instanceof NoConnectionError) {
                    messageRespone("Tidak ada koneksi");
                } else if (error instanceof TimeoutError) {
                    messageRespone("Koneksi Timeout");
                }

            }
        }) {
            @Override
            protected Map<String, String> getParams() {
                Map<String, String> jsonParams = new HashMap<String, String>();
                return jsonParams;
            }

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> params = new HashMap<String, String>();
                params.put("Content-Type", "application/x-www-form-urlencoded");
                return params;
            }
        };
        sr_get_all_new_photo_user.setRetryPolicy(new DefaultRetryPolicy(
                Variabel.MY_SOCKET_TIMEOUT_MS_NEWS,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
        queue_get_new_all_photo_user.add(sr_get_all_new_photo_user);

    }

the result from java is :

{
  "isSuccess": true,
  "message": "ok",
  "pageCurrent": "1",
  "pageTotal": 1,
  "itemsTotal": 2,
  "memberProfilePictures": [
    {
      "photoMemberId": "O6lXnljaVabh55dd08c87b59c55dd08c87b64255dd08c87b6e4e5cAv",
      "photoMemberIdMember": "LWC6MZOgIZxB559c5af5ca70c559c5af5ca7b2559c5af5ca855TiMPZ",
      "photoMemberStatus": 1,
      "photoMemberURL": "https://assac.com/public/uploads/pictures/2015_08_26/1440549064367_medium.png",
      "photoMemberURLLarge": "https://assac.com/public/uploads/pictures/2015_08_26/1440549064367_large.png",
      "photoMemberWidth": 480,
      "photoMemberHeight": 700
    },
    {
      "photoMemberId": "QNRiYnQKk8V755d931c44efcd55d931c44f07155d931c44f11efffVd",
      "photoMemberIdMember": "LWC6MZOgIZxB559c5af5ca70c559c5af5ca7b2559c5af5ca855TiMPZ",
      "photoMemberStatus": 0,
      "photoMemberURL": "https://assac.com/public/uploads/pictures/2015_08_23/14402974122618_medium.jpeg",
      "photoMemberURLLarge": "https://assac.com/public/uploads/pictures/2015_08_23/14402974122618_large.jpeg",
      "photoMemberWidth": 480,
      "photoMemberHeight": 269
    }
  ]
}

but result from browser is :

{
  "isSuccess": true,
  "message": "ok",
  "pageCurrent": "1",
  "pageTotal": 1,
  "itemsTotal": 4,
  "memberProfilePictures": [
    {
      "photoMemberId": "kmz9RnqQmi2I55f7bc9eb023955f7bc9eb02df55f7bc9eb0381v2PqG",
      "photoMemberIdMember": "LWC6MZOgIZxB559c5af5ca70c559c5af5ca7b2559c5af5ca855TiMPZ",
      "photoMemberStatus": 0,
      "photoMemberURL": "https://assac.com/public/uploads/pictures/2015_09_15/14422990385762_medium.jpeg",
      "photoMemberURLLarge": "https://assac.com/public/uploads/pictures/2015_09_15/14422990385762_large.jpeg",
      "photoMemberWidth": 480,
      "photoMemberHeight": 640
    },
    {
      "photoMemberId": "O6lXnljaVabh55dd08c87b59c55dd08c87b64255dd08c87b6e4e5cAv",
      "photoMemberIdMember": "LWC6MZOgIZxB559c5af5ca70c559c5af5ca7b2559c5af5ca855TiMPZ",
      "photoMemberStatus": 1,
      "photoMemberURL": "https://assac.com/public/uploads/pictures/2015_08_26/1440549064367_medium.png",
      "photoMemberURLLarge": "https://assac.com/public/uploads/pictures/2015_08_26/1440549064367_large.png",
      "photoMemberWidth": 480,
      "photoMemberHeight": 700
    },
    {
      "photoMemberId": "QNRiYnQKk8V755d931c44efcd55d931c44f07155d931c44f11efffVd",
      "photoMemberIdMember": "LWC6MZOgIZxB559c5af5ca70c559c5af5ca7b2559c5af5ca855TiMPZ",
      "photoMemberStatus": 0,
      "photoMemberURL": "https://assac.com/public/uploads/pictures/2015_08_23/14402974122618_medium.jpeg",
      "photoMemberURLLarge": "https://assac.com/public/uploads/pictures/2015_08_23/14402974122618_large.jpeg",
      "photoMemberWidth": 480,
      "photoMemberHeight": 269
    },
    {
      "photoMemberId": "WwJHWP9ZQWhr55f7bc849ecec55f7bc849ed9055f7bc849ee41P6Ebd",
      "photoMemberIdMember": "LWC6MZOgIZxB559c5af5ca70c559c5af5ca7b2559c5af5ca855TiMPZ",
      "photoMemberStatus": 0,
      "photoMemberURL": "https://assac.com/public/uploads/pictures/2015_09_15/14422990125018_medium.jpeg",
      "photoMemberURLLarge": "https://assac.com/public/uploads/pictures/2015_09_15/14422990125018_large.jpeg",
      "photoMemberWidth": 480,
      "photoMemberHeight": 853
    }
  ]
}

so how to fix it ?

As it seems your Variabel.LIMIT_DATA is 2 , so the answer is different. Set it to 10 (as it is in your URL) and you should have the same results (maybe not the same order).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM