Fix v2 api requests
This commit is contained in:
parent
1aec456d89
commit
d53f92f573
1 changed files with 8 additions and 3 deletions
|
|
@ -2,6 +2,7 @@ package com.bbn.hadder.utils;
|
||||||
|
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -20,9 +21,13 @@ public class Request {
|
||||||
try {
|
try {
|
||||||
Response response = caller.newCall(request).execute();
|
Response response = caller.newCall(request).execute();
|
||||||
JSONObject json = new JSONObject(response.body().string());
|
JSONObject json = new JSONObject(response.body().string());
|
||||||
JSONObject data = json.getJSONObject("data");
|
try {
|
||||||
JSONObject response1 = data.getJSONObject("response");
|
JSONObject data = json.getJSONObject("data");
|
||||||
return response1.toString().replace("{\"url\":\"", "").replace("\"}", "");
|
JSONObject response1 = data.getJSONObject("response");
|
||||||
|
return response1.toString().replace("{\"url\":\"", "").replace("\"}", "");
|
||||||
|
} catch (Exception ignore) {
|
||||||
|
return json.getString("url");
|
||||||
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue