This repository was archived by the owner on Jul 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCat.java
More file actions
93 lines (76 loc) · 2.39 KB
/
Copy pathCat.java
File metadata and controls
93 lines (76 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package API;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import Main.Static;
public class Cat {
private Long code;
private String cat;
private String raw;
public Cat() {
try {
String url = "https://"+Static.server + "/api/v1/suprise_me";
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("User-Agent", "Mozilla/5.0");
@SuppressWarnings("unused")
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getErrorStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
raw = response.toString();
JSONParser parser = new JSONParser();
Object obj2 = parser.parse(raw);
JSONObject jsonObject = (JSONObject) obj2;
code = (Long) jsonObject.get("code");
cat = (String) jsonObject.get("cats");
}catch(Exception e) {
e.printStackTrace();
}
}
public Long getCode() {
return code;
}
public String getCat() {
return cat;
}
public String getRawJSON() {
return raw;
}
public void Refresh() {
try {
String url = "https://enjuu.click/api/v1/suprise_me";
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("User-Agent", "Mozilla/5.0");
@SuppressWarnings("unused")
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getErrorStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
raw = response.toString();
JSONParser parser = new JSONParser();
Object obj2 = parser.parse(raw);
JSONObject jsonObject = (JSONObject) obj2;
code = (Long) jsonObject.get("code");
cat = (String) jsonObject.get("cats");
}catch(Exception e) {
e.printStackTrace();
}
}
}