Showing
1 changed file
with
14 additions
and
2 deletions
... | @@ -17,6 +17,8 @@ import java.io.InputStreamReader; | ... | @@ -17,6 +17,8 @@ import java.io.InputStreamReader; |
17 | import java.io.OutputStream; | 17 | import java.io.OutputStream; |
18 | import java.net.HttpURLConnection; | 18 | import java.net.HttpURLConnection; |
19 | import java.net.URL; | 19 | import java.net.URL; |
20 | +import java.util.Iterator; | ||
21 | +import java.util.Set; | ||
20 | 22 | ||
21 | public class Api { | 23 | public class Api { |
22 | public interface Callback { | 24 | public interface Callback { |
... | @@ -32,8 +34,18 @@ public class Api { | ... | @@ -32,8 +34,18 @@ public class Api { |
32 | public void run() { | 34 | public void run() { |
33 | ApiResult apiResult; | 35 | ApiResult apiResult; |
34 | try { | 36 | try { |
35 | - Log.d("test", "callApi"); | 37 | + String queryString = ""; |
36 | - URL url = new URL("http://" + Api.DOMAIN + endpoint); | 38 | + if(("GET".equals(method) || "DELETE".equals(method)) && params != null) { |
39 | + Set<String> keys = params.keySet(); | ||
40 | + Iterator<String> iter = keys.iterator(); | ||
41 | + while(iter.hasNext()) { | ||
42 | + String key = iter.next(); | ||
43 | + queryString += "&" + key + "=" + params.get(key).getAsString(); | ||
44 | + } | ||
45 | + queryString = "?" + queryString.substring(1); | ||
46 | + } | ||
47 | + | ||
48 | + URL url = new URL("http://" + Api.DOMAIN + endpoint + queryString); | ||
37 | HttpURLConnection conn = (HttpURLConnection) url.openConnection(); | 49 | HttpURLConnection conn = (HttpURLConnection) url.openConnection(); |
38 | conn.setRequestMethod(method); | 50 | conn.setRequestMethod(method); |
39 | 51 | ... | ... |
-
Please register or login to post a comment