Release v1.0.0 #345
1 changed files with 31 additions and 0 deletions
31
src/main/java/com/bbn/hadder/utils/Request.java
Normal file
31
src/main/java/com/bbn/hadder/utils/Request.java
Normal 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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue