|
@@ -1,3 +1,12 @@
|
|
1
|
+import org.apache.http.HttpEntity;
|
|
2
|
+import org.apache.http.client.methods.CloseableHttpResponse;
|
|
3
|
+import org.apache.http.client.methods.HttpGet;
|
|
4
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
5
|
+import org.apache.http.impl.client.HttpClients;
|
|
6
|
+import org.apache.http.util.EntityUtils;
|
|
7
|
+
|
|
8
|
+import java.io.IOException;
|
|
9
|
+
|
1
|
10
|
public class YouAreEll {
|
2
|
11
|
|
3
|
12
|
YouAreEll() {
|
|
@@ -5,19 +14,49 @@ public class YouAreEll {
|
5
|
14
|
|
6
|
15
|
public static void main(String[] args) {
|
7
|
16
|
YouAreEll urlhandler = new YouAreEll();
|
8
|
|
- System.out.println(urlhandler.MakeURLCall("/ids", "GET", ""));
|
9
|
|
- System.out.println(urlhandler.MakeURLCall("/messages", "GET", ""));
|
|
17
|
+ try {
|
|
18
|
+ System.out.println(urlhandler.MakeURLCall("/ids", "GET", ""));
|
|
19
|
+ System.out.println(urlhandler.MakeURLCall("/messages", "GET", ""));
|
|
20
|
+ } catch (IOException e) {
|
|
21
|
+ e.printStackTrace();
|
|
22
|
+ }
|
10
|
23
|
}
|
11
|
24
|
|
12
|
25
|
public String get_ids() {
|
13
|
|
- return MakeURLCall("/ids", "GET", "");
|
|
26
|
+ String temp = null;
|
|
27
|
+ try {
|
|
28
|
+ temp = MakeURLCall("/ids", "GET", "");
|
|
29
|
+ } catch (IOException e) {
|
|
30
|
+ e.printStackTrace();
|
|
31
|
+ }
|
|
32
|
+ return temp;
|
14
|
33
|
}
|
15
|
34
|
|
16
|
35
|
public String get_messages() {
|
17
|
|
- return MakeURLCall("/messages", "GET", "");
|
|
36
|
+ String temp = null;
|
|
37
|
+ try {
|
|
38
|
+ temp = MakeURLCall("/messages", "GET", "");
|
|
39
|
+ } catch (IOException e) {
|
|
40
|
+ e.printStackTrace();
|
|
41
|
+ }
|
|
42
|
+ return temp;
|
18
|
43
|
}
|
19
|
44
|
|
20
|
|
- public String MakeURLCall(String mainurl, String method, String jpayload) {
|
21
|
|
- return "nada";
|
|
45
|
+ public String MakeURLCall(String mainurl, String method, String jpayload) throws IOException {
|
|
46
|
+ String baseURL = "http://zipcode.rocks:8085";
|
|
47
|
+ String response;
|
|
48
|
+
|
|
49
|
+ CloseableHttpClient closeableHttpClient = HttpClients.createDefault();
|
|
50
|
+
|
|
51
|
+ HttpGet httpGet = new HttpGet(baseURL + mainurl);
|
|
52
|
+
|
|
53
|
+ CloseableHttpResponse response1 = closeableHttpClient.execute(httpGet);
|
|
54
|
+
|
|
55
|
+ HttpEntity httpEntity = response1.getEntity();
|
|
56
|
+
|
|
57
|
+ response = EntityUtils.toString(httpEntity);
|
|
58
|
+
|
|
59
|
+ return response;
|
|
60
|
+
|
22
|
61
|
}
|
23
|
62
|
}
|