Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void fnCallLoginAPI() {
- try {
- //DEMO URL
- //final String URL="http://demo.io/api/api.php?m=login";
- //LIVE URL
- final String URL = "https://www.live.com/shop/api/api.php?m=login";
- final String requestBody = "email=abc.b@xyz.com" + "&password=43443==" + "&strPlatform=i" + "&strDeviceToken=null";
- StringRequest stringRequest = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() {
- @Override
- public void onResponse(String response) {
- String strResponse = response;
- System.out.println("THE RESPONSE IS in PROFILE IS" + response);
- }
- },
- new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- }
- })
- {
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- Map<String, String> headers = new HashMap<>();
- headers.put("Cookie", "PHPSESSID=" + sessionID);
- return headers;
- }
- @Override
- public byte[] getBody() throws AuthFailureError {
- byte[] body = new byte[0];
- try {
- System.out.println("THE REQIEST BODY IS" + requestBody);
- body = requestBody.getBytes("UTF-8");
- } catch (UnsupportedEncodingException e) {
- Log.e("TAG", "Unable to gets bytes from JSON", e.fillInStackTrace());
- }
- return body;
- }
- };
- AppApplication.getInstance().addToRequestQueue(stringRequest, "assignment");
- } catch (Exception e) {
- }
- }
- public void fnCallCateGoryAPI(){
- try { final String URL ="https://www.live.com/shop/api/api.php?m=getcategories";
- StringRequest stringRequest = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() {
- @Override
- public void onResponse(String response) {
- String strResponse = response;
- System.out.println("THE RESPONSE IS in PROFILE IS" + response);
- JSONObject jsonObj = null;
- try {
- jsonObj = new JSONObject(strResponse);
- sessionID = jsonObj.optString("session_id");
- System.out.print("sessionID" + sessionID);
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- },
- new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- }
- })
- {
- };
- AppApplication.getInstance().addToRequestQueue(stringRequest, "assignment");
- } catch (Exception e) {}
- }}
Add Comment
Please, Sign In to add comment