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