|
@@ -1,3 +1,13 @@
|
|
1
|
+import java.io.IOException;
|
|
2
|
+import java.net.HttpURLConnection;
|
|
3
|
+import java.net.MalformedURLException;
|
|
4
|
+import java.net.ProtocolException;
|
|
5
|
+import java.net.URL;
|
|
6
|
+import java.io.BufferedReader;
|
|
7
|
+import java.io.InputStreamReader;
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
1
|
11
|
public class YouAreEll {
|
2
|
12
|
|
3
|
13
|
YouAreEll() {
|
|
@@ -13,11 +23,58 @@ public class YouAreEll {
|
13
|
23
|
return MakeURLCall("/ids", "GET", "");
|
14
|
24
|
}
|
15
|
25
|
|
|
26
|
+
|
16
|
27
|
public String get_messages() {
|
17
|
28
|
return MakeURLCall("/messages", "GET", "");
|
18
|
29
|
}
|
19
|
30
|
|
20
|
31
|
public String MakeURLCall(String mainurl, String method, String jpayload) {
|
21
|
|
- return "nada";
|
|
32
|
+ String output= null;
|
|
33
|
+ String methodUrl="http://zipcode.rocks:8085" + mainurl;
|
|
34
|
+ URL obj = null;
|
|
35
|
+ try {
|
|
36
|
+ obj = new URL(methodUrl);
|
|
37
|
+ } catch (MalformedURLException e) {
|
|
38
|
+ e.printStackTrace();
|
|
39
|
+ }
|
|
40
|
+ HttpURLConnection con = null;
|
|
41
|
+ try {
|
|
42
|
+ con = (HttpURLConnection) obj.openConnection();
|
|
43
|
+ } catch (IOException e) {
|
|
44
|
+ e.printStackTrace();
|
|
45
|
+ }
|
|
46
|
+ try {
|
|
47
|
+ con.setRequestMethod(method);
|
|
48
|
+ } catch (ProtocolException e) {
|
|
49
|
+ e.printStackTrace();
|
|
50
|
+ }
|
|
51
|
+
|
|
52
|
+ try {
|
|
53
|
+ int responseCode = con.getResponseCode();
|
|
54
|
+ //System.out.println(responseCode);
|
|
55
|
+ } catch (IOException e) {
|
|
56
|
+ e.printStackTrace();
|
|
57
|
+ }
|
|
58
|
+
|
|
59
|
+ BufferedReader br = null;
|
|
60
|
+ try {
|
|
61
|
+ br = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
|
62
|
+ StringBuilder sb = new StringBuilder();
|
|
63
|
+ String line;
|
|
64
|
+ while ((line = br.readLine()) != null) {
|
|
65
|
+ sb.append(line+"\n");
|
|
66
|
+ }
|
|
67
|
+ br.close();
|
|
68
|
+ output = sb.toString();
|
|
69
|
+ } catch (IOException e) {
|
|
70
|
+ e.printStackTrace();
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ return output;
|
22
|
74
|
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
23
|
80
|
}
|