Fix v2 api requests

This commit is contained in:
GregTCLTK 2020-01-20 20:31:19 +01:00
parent 1aec456d89
commit d53f92f573
No known key found for this signature in database
GPG key ID: A91BADE5C070FF67

View file

@ -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();
}