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.Response;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -20,9 +21,13 @@ public class Request {
|
|||
try {
|
||||
Response response = caller.newCall(request).execute();
|
||||
JSONObject json = new JSONObject(response.body().string());
|
||||
JSONObject data = json.getJSONObject("data");
|
||||
JSONObject response1 = data.getJSONObject("response");
|
||||
return response1.toString().replace("{\"url\":\"", "").replace("\"}", "");
|
||||
try {
|
||||
JSONObject data = json.getJSONObject("data");
|
||||
JSONObject response1 = data.getJSONObject("response");
|
||||
return response1.toString().replace("{\"url\":\"", "").replace("\"}", "");
|
||||
} catch (Exception ignore) {
|
||||
return json.getString("url");
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue