0

I have implemented login page, where I used volley library to send the data on server side. So please anyone tell me how to send data to server where login request in array and JSON like below. I know this question is already asked by some one but I need with Volley.

login request in array :-   Array ( [User] => Array ( [username] => user [password] => India2016 ['service_auth']=>ture) )

login request in json:-    {"User":{"username":"user","password":"India2016","service_aut"=>ture}} 

Below is my code

private void LoginRequest() {
    StringRequest stringRequest = new StringRequest(Request.Method.POST, LoginURL,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    //showJSON(response);
                    Log.e("user_______",userId);
                    Log.e("pass_______",pass);
                    Log.e("response Login_________",response);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Toast.makeText(LoginActivity.this, " no internet connection", Toast.LENGTH_LONG).show();
                }
            }) {
        @Override
        protected Map<String, String> getParams() throws AuthFailureError {
            Map<String, String> map = new HashMap<String, String>();
            map.put(KEY_EMAIL, userId);
            map.put(KEY_PASSWORD, pass);
            return map;
        }
    };
    RequestQueue requestQueue = Volley.newRequestQueue(LoginActivity.this);
    requestQueue.add(stringRequest);
Paramjeet Singh
  • 145
  • 1
  • 3
  • 15
  • Thanks for reply @Nilesh but my question is different to your link – Paramjeet Singh Feb 23 '18 at 10:40
  • check out this links it may help you https://www.google.co.in/search?client=ubuntu&channel=fs&q=how+to+send+data+to+server+using+volley+in+andoird&ie=utf-8&oe=utf-8&gfe_rd=cr&dcr=0&ei=u--PWqbhAYnz8AecxJCwBw – AskNilesh Feb 23 '18 at 10:41
  • I asked this question just because I haven't php file. I know only these two line which is given by someone who implement php file. – Paramjeet Singh Feb 23 '18 at 10:43
  • If the string is comma separated then I well know how to send but in these case how can send – Paramjeet Singh Feb 23 '18 at 10:48

0 Answers0