Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void postEmailandPassword(final String email, final String data) {
- StringRequest authenticateRequest = new StringRequest(Request.Method.POST, Constants.AUTHENTICATE_URL,
- new Response.Listener<String>() {
- @Override
- public void onResponse(String response) {
- Log.e("response", response.toString());
- if(response.trim().equals("success")){
- // openProfile();
- }else{
- Log.e("response", response.toString());
- Toast.makeText(LoginActivity.this,response,Toast.LENGTH_LONG).show();
- }
- }
- },
- new Response.ErrorListener() {
- @Override
- public void onErrorResponse( VolleyError volleyError ) {
- try {
- String responseBody = new String( volleyError.networkResponse.data, "utf-8" );
- JSONObject jsonObject = new JSONObject( responseBody );
- } catch ( JSONException e ) {
- //Handle a malformed json response
- } catch (UnsupportedEncodingException error){
- }
- }
- }){
- @Override
- protected Map<String, String> getParams() throws AuthFailureError {
- Map<String,String> map = new HashMap<String,String>();
- map.put("email",email);
- map.put("password",data);
- return map;
- }
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- Map<String, String> params = new HashMap<String, String>();
- params.put("x-session-id", "sessie-random-string-proshore");
- params.put("Authorization", "Basic cHJvc2hvcmU6c2hvcmVwcm8=");
- params.put("x-user-id", "22320");
- params.put("Accept-Language", "nl");
- params.put("Content-Type", "application/json; charset=utf-8");
- return params;
- }
- };
- RequestQueue requestQueue = Volley.newRequestQueue(this);
- requestQueue.add(authenticateRequest);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement