Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
- JSONObject object = new JSONObject();
- try {
- //input your API parameters
- object.put("login", ed1.getText());
- object.put("password", ed2.getText());
- }
- catch (JSONException e) {
- e.printStackTrace();
- }
- // Enter the correct url for your api service site
- String apiUrl = Helper.getConfigValue(MainActivity.super.getApplicationContext(), "api_url");
- apiUrl = apiUrl + "/auth";
- JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, apiUrl, object,
- new Response.Listener<JSONObject>() {
- @Override
- public void onResponse(JSONObject response) {
- apiToken = ("String Response : " + response.toString());
- Context context = getApplicationContext();
- CharSequence text = apiToken;
- int duration = Toast.LENGTH_SHORT;
- Toast toast = Toast.makeText(context, text, duration);
- toast.show();
- response.
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- Context context = getApplicationContext();
- CharSequence text = ""+error.networkResponse;
- int duration = Toast.LENGTH_SHORT;
- Toast toast = Toast.makeText(context, text, duration);
- toast.show();
- }
- });
- requestQueue.add(jsonObjectRequest);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement