|
@@ -433,6 +433,52 @@ public class LifeCenterFunction {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static String httpUrlCon(String apiUrl, String param) {
|
|
|
|
+ String result = "";
|
|
|
|
+ URL url;
|
|
|
|
+ try {
|
|
|
|
+ url = new URL(apiUrl);
|
|
|
|
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
|
|
+// conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
|
|
|
+ conn.setRequestProperty("Content-Type", "application/json;utf-8");
|
|
|
|
+ conn.setRequestProperty("Accept", "application/json");
|
|
|
|
+ conn.setRequestMethod("POST"); // post방식 통신
|
|
|
|
+ conn.setDoOutput(true); // 쓰기모드 지정
|
|
|
|
+ conn.setDoInput(true); // 읽기모드 지정
|
|
|
|
+ conn.setUseCaches(false); // 캐싱데이터를 받을지 안받을지
|
|
|
|
+ conn.setDefaultUseCaches(false); // 캐싱데이터 디폴트 값 설정
|
|
|
|
+ conn.setReadTimeout(10000); // 타임아웃 10초
|
|
|
|
+
|
|
|
|
+ OutputStream os = conn.getOutputStream(); // 서버로 보내기 위한 출력 스트림
|
|
|
|
+ byte[] input = param.getBytes("utf-8");
|
|
|
|
+ os.write(input, 0, input.length);
|
|
|
|
+ os.close();
|
|
|
|
+
|
|
|
|
+ InputStream is = conn.getInputStream(); //데이타를 받기위 구멍을 열어준다
|
|
|
|
+ StringBuilder builder = new StringBuilder(); //문자열을 담기 위한 객체
|
|
|
|
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is,"UTF-8")); //문자열 셋 세팅
|
|
|
|
+
|
|
|
|
+ String line;
|
|
|
|
+ while ((line = reader.readLine()) != null) {
|
|
|
|
+ builder.append(line+ "\n");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// logger.error("httpUrlConnection Result -- > " + builder.toString());
|
|
|
|
+ result = builder.toString();
|
|
|
|
+
|
|
|
|
+ conn.disconnect();
|
|
|
|
+ } catch (MalformedURLException e) {
|
|
|
|
+ // TODO Auto-generated catch block
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ // TODO Auto-generated catch block
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
private static String getPostString(HashMap<String, String> map) {
|
|
private static String getPostString(HashMap<String, String> map) {
|
|
StringBuilder result = new StringBuilder();
|
|
StringBuilder result = new StringBuilder();
|
|
boolean first = true; // 첫 번째 매개변수 여부
|
|
boolean first = true; // 첫 번째 매개변수 여부
|