Request file lol

This commit is contained in:
GregTCLTK 2020-01-20 19:11:34 +01:00
parent 607d633d7f
commit c094a0e5f1
No known key found for this signature in database
GPG key ID: A91BADE5C070FF67

View file

@ -0,0 +1,31 @@
package com.bbn.hadder.utils;
import okhttp3.OkHttpClient;
import okhttp3.Response;
import org.json.JSONObject;
import java.io.IOException;
/**
* @author Skidder / GregTCLTK
*/
public class Request {
public static String get(String url) {
OkHttpClient caller = new OkHttpClient();
okhttp3.Request request = new okhttp3.Request.Builder().url(url).build();
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("\"}", "");
} catch (IOException ex) {
ex.printStackTrace();
}
return null;
}
}