From 961cba16674f2f9b2042ad54fbe140590b5b3168 Mon Sep 17 00:00:00 2001 From: "hehihoho3@gmail.com" Date: Wed, 10 Sep 2025 18:35:35 +0900 Subject: [PATCH] =?UTF-8?q?api=20=EA=B0=9C=EC=84=A0=20=EC=A7=84=ED=96=89?= =?UTF-8?q?=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/sms/web/ApiSmsTestMsgController.java | 31 +- .../uss/umt/web/EgovUserManageController.java | 1 + .../egovProps/globals_dev.properties | 3 + .../egovProps/globals_local.properties | 3 + .../egovProps/globals_prod.properties | 5 +- src/main/webapp/WEB-INF/decorators.xml | 7 + .../jsp/uss/ion/api/test/sms/sendMsgForm.jsp | 6 + .../jsp_example_inqry_chnlid_form_r1.jsp | 149 ++++++++ .../jsp_example_inqry_chnlid_r1.jsp | 94 +++++ ...example_inqry_templates_detail_form_r1.jsp | 333 ++++++++++++++++++ .../jsp_example_inqry_templates_detail_r1.jsp | 109 ++++++ ...p_example_inqry_templates_list_form_r1.jsp | 182 ++++++++++ .../jsp_example_inqry_templates_list_r1.jsp | 102 ++++++ .../jsp_example_send_at_form_r1.jsp | 283 +++++++++++++++ .../sample_mjon/jsp_example_send_at_r1.jsp | 108 ++++++ .../jsp_example_send_ft_form_r1.jsp | 107 ++++++ .../sample_mjon/jsp_example_send_ft_r1.jsp | 189 ++++++++++ .../sample_mjon/jsp_example_send_msg_r1.jsp | 6 +- .../sample_mjon/jsp_example_start_form_r1.jsp | 8 + .../jsp_example_start_form_r1_backup.jsp | 23 ++ 20 files changed, 1732 insertions(+), 17 deletions(-) create mode 100644 src/main/webapp/sample_mjon/jsp_example_inqry_chnlid_form_r1.jsp create mode 100644 src/main/webapp/sample_mjon/jsp_example_inqry_chnlid_r1.jsp create mode 100644 src/main/webapp/sample_mjon/jsp_example_inqry_templates_detail_form_r1.jsp create mode 100644 src/main/webapp/sample_mjon/jsp_example_inqry_templates_detail_r1.jsp create mode 100644 src/main/webapp/sample_mjon/jsp_example_inqry_templates_list_form_r1.jsp create mode 100644 src/main/webapp/sample_mjon/jsp_example_inqry_templates_list_r1.jsp create mode 100644 src/main/webapp/sample_mjon/jsp_example_send_at_form_r1.jsp create mode 100644 src/main/webapp/sample_mjon/jsp_example_send_at_r1.jsp create mode 100644 src/main/webapp/sample_mjon/jsp_example_send_ft_form_r1.jsp create mode 100644 src/main/webapp/sample_mjon/jsp_example_send_ft_r1.jsp create mode 100644 src/main/webapp/sample_mjon/jsp_example_start_form_r1_backup.jsp diff --git a/src/main/java/itn/let/mjo/api/sms/web/ApiSmsTestMsgController.java b/src/main/java/itn/let/mjo/api/sms/web/ApiSmsTestMsgController.java index b388a09..4001ccc 100644 --- a/src/main/java/itn/let/mjo/api/sms/web/ApiSmsTestMsgController.java +++ b/src/main/java/itn/let/mjo/api/sms/web/ApiSmsTestMsgController.java @@ -2,6 +2,7 @@ package itn.let.mjo.api.sms.web; import javax.servlet.http.HttpServletRequest; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.ModelAttribute; @@ -26,6 +27,18 @@ import itn.let.mjo.apikey.service.ApiKeyVO; @Controller public class ApiSmsTestMsgController { + + /** xpedite 솔루션 ID*/ + @Value("#{globalSettings['Globals.api.ip']}") + private String API_IP; + + + // [ADD] 모든 요청에 공통으로 API_IP 넣기 + @ModelAttribute("API_IP") + public String addApiIp() { + return API_IP; + } + /** * @methodName : ussIonApikeyUserAPIKEYList * @author : 이호영 @@ -43,9 +56,7 @@ public class ApiSmsTestMsgController { public String sendMsgForm(@ModelAttribute("searchVO") ApiKeyVO searchVO, HttpServletRequest request , ModelMap model) throws Exception{ - //value 값 가져오기 - return "/uss/ion/api/test/sms/sendMsgForm"; } @@ -54,9 +65,7 @@ public class ApiSmsTestMsgController { public String sendMsgsForm(@ModelAttribute("searchVO") ApiKeyVO searchVO, HttpServletRequest request , ModelMap model) throws Exception{ - //value 값 가져오기 - - + return "/uss/ion/api/test/sms/sendMsgsForm"; } @@ -66,9 +75,7 @@ public class ApiSmsTestMsgController { public String sendHstryFrom(@ModelAttribute("searchVO") ApiKeyVO searchVO, HttpServletRequest request , ModelMap model) throws Exception{ - //value 값 가져오기 - - + return "/uss/ion/api/test/sms/sendHstryFrom"; } @@ -78,9 +85,7 @@ public class ApiSmsTestMsgController { public String sendHstryDetailFrom(@ModelAttribute("searchVO") ApiKeyVO searchVO, HttpServletRequest request , ModelMap model) throws Exception{ - //value 값 가져오기 - - + return "/uss/ion/api/test/sms/sendHstryDetailFrom"; } @@ -90,9 +95,7 @@ public class ApiSmsTestMsgController { public String sendSelectPriceFrom(@ModelAttribute("searchVO") ApiKeyVO searchVO, HttpServletRequest request , ModelMap model) throws Exception{ - //value 값 가져오기 - - + return "/uss/ion/api/test/sms/sendSelectPriceFrom"; } diff --git a/src/main/java/itn/let/uss/umt/web/EgovUserManageController.java b/src/main/java/itn/let/uss/umt/web/EgovUserManageController.java index d3e44d0..5b64942 100644 --- a/src/main/java/itn/let/uss/umt/web/EgovUserManageController.java +++ b/src/main/java/itn/let/uss/umt/web/EgovUserManageController.java @@ -2722,6 +2722,7 @@ public class EgovUserManageController { msg = "로그인이 필요합니다."; } else { + userManageService.updateOneUserSmishingYn(userManageVO); } } catch (Exception e) { diff --git a/src/main/resources/egovframework/egovProps/globals_dev.properties b/src/main/resources/egovframework/egovProps/globals_dev.properties index 7f00f54..58e8203 100644 --- a/src/main/resources/egovframework/egovProps/globals_dev.properties +++ b/src/main/resources/egovframework/egovProps/globals_dev.properties @@ -124,3 +124,6 @@ Globals.pay.kgm.mobile.payMode=00 #Slack Globals.slack.hooks.url=https://hooks.slack.com/services/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 Globals.slack.channel.name=\ud14c\uc2a4\ud2b8_mjon\uba54\uc2dc\uc9c0 + +#API +Globals.api.ip=http://119.193.215.98:8087 diff --git a/src/main/resources/egovframework/egovProps/globals_local.properties b/src/main/resources/egovframework/egovProps/globals_local.properties index 2a06a43..7b59c6b 100644 --- a/src/main/resources/egovframework/egovProps/globals_local.properties +++ b/src/main/resources/egovframework/egovProps/globals_local.properties @@ -125,3 +125,6 @@ Globals.pay.kgm.mobile.payMode=00 #Slack Globals.slack.hooks.url=https://hooks.slack.com/services/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 Globals.slack.channel.name=\ud14c\uc2a4\ud2b8_mjon\uba54\uc2dc\uc9c0 + +#API +Globals.api.ip=http://119.193.215.98:8087 diff --git a/src/main/resources/egovframework/egovProps/globals_prod.properties b/src/main/resources/egovframework/egovProps/globals_prod.properties index 185aadd..479d0e6 100644 --- a/src/main/resources/egovframework/egovProps/globals_prod.properties +++ b/src/main/resources/egovframework/egovProps/globals_prod.properties @@ -105,4 +105,7 @@ Globals.pay.kgm.mobile.payMode=10 #Slack Globals.slack.hooks.url=https://hooks.slack.com/services/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 -Globals.slack.channel.name=mjon\uba54\uc2dc\uc9c0 \ No newline at end of file +Globals.slack.channel.name=mjon\uba54\uc2dc\uc9c0 + +#API +Globals.api.ip=https://api.munjaon.co.kr \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/decorators.xml b/src/main/webapp/WEB-INF/decorators.xml index 45c14db..92bdf65 100644 --- a/src/main/webapp/WEB-INF/decorators.xml +++ b/src/main/webapp/WEB-INF/decorators.xml @@ -32,6 +32,13 @@ /sample_mjon/jsp_example_select_price_form_r1.jsp /sample_mjon/jsp_example_start_form_r1.jsp /sample_mjon/jsp_example_select_price_form_r1.jsp + /sample_mjon/* + + diff --git a/src/main/webapp/WEB-INF/jsp/uss/ion/api/test/sms/sendMsgForm.jsp b/src/main/webapp/WEB-INF/jsp/uss/ion/api/test/sms/sendMsgForm.jsp index c2a1740..72c0743 100644 --- a/src/main/webapp/WEB-INF/jsp/uss/ion/api/test/sms/sendMsgForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/uss/ion/api/test/sms/sendMsgForm.jsp @@ -70,6 +70,10 @@ + + + + +
+
+ +
+
+

돌아가기

+
+ +

알림톡 채널ID 조회(샘플-문자온)

+ *mberId와 accessKey값은 실제 서비스시에는 jsp_example_inqry_chnlid_r1.jsp 파일에 작성하여 사용하세요 +
(샘플 페이지에서는 월활한 테스트를 위해 파라미터 형식으로 제공합니다.) +


+ +
+
+
+ + + +
+   +
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + +
발신프로필키(SenderKey)핸드폰번호채널ID(@ID)등록일자
+
+ +
+ +
+
\ No newline at end of file diff --git a/src/main/webapp/sample_mjon/jsp_example_inqry_chnlid_r1.jsp b/src/main/webapp/sample_mjon/jsp_example_inqry_chnlid_r1.jsp new file mode 100644 index 0000000..1d27fe1 --- /dev/null +++ b/src/main/webapp/sample_mjon/jsp_example_inqry_chnlid_r1.jsp @@ -0,0 +1,94 @@ +<%@page import="java.io.InputStreamReader"%> +<%@page import="java.io.BufferedReader"%> +<%@page import="org.apache.http.HttpResponse"%> +<%@page import="org.apache.http.client.methods.HttpPost"%> +<%@page import="org.apache.http.impl.client.HttpClients"%> +<%@page import="org.apache.http.client.HttpClient"%> +<%@page import="org.apache.http.HttpEntity"%> +<%@page import="java.net.URLEncoder"%> +<%@page import="org.apache.http.entity.ContentType"%> +<%@page import="java.util.Iterator"%> +<%@page import="java.nio.charset.Charset"%> +<%@page import="org.apache.http.entity.mime.HttpMultipartMode"%> +<%@page import="org.apache.http.entity.mime.MultipartEntityBuilder"%> +<%@page import="java.util.HashMap"%> +<%@page import="java.util.Map"%> +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> +<% + try{ + //기본 설정값 + final String encodingType = "UTF-8"; + final String boundary = "____boundary____"; + + //회원아이디, APIKEY - 보안을 위해 실제 서비스 시에는 이곳에 mberId와 apiKey 값을 적어서 사용 + //실제서비스용 + final String mberId = "dudgusw"; //문자온 로그인 아이디 + final String apiKey = "3429312e6a2c732188d4cc7d15d8a1baa01d8d91"; //발급받은 api key + + //테스트용 + //String mberId = request.getParameter("p_mberId"); //문자온 로그인 아이디 + //String apiKey = request.getParameter("p_apiKey"); //발급받은 api key + + /******************** 전송 요청 URL ********************/ + final String apiUrl = "http://119.193.215.98:8087/api/kakao/inqry/chnlId"; //채널ID 조회 API URL + + Map params = new HashMap(); + + //기본 전송 데이터 + params.put("mberId", mberId); //회원 아이디 + params.put("accessKey", apiKey); //인증키 + + //REST API 전송 + String result = ""; + + MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + + builder.setBoundary(boundary); + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + builder.setCharset(Charset.forName(encodingType)); + + try{ + for(Iterator i = params.keySet().iterator(); i.hasNext();){ + String key = i.next(); + //전달값이 없는 경우 오류 + try{ + String value = params.get(key); + if(value != null) { + builder.addTextBody(key, value, ContentType.create("Multipart/related", encodingType)); + } + }catch(Exception ex){ + ex.printStackTrace(); + } + } + }catch(Exception ex){ + ex.printStackTrace(); + } + + HttpEntity entity = builder.build(); + + HttpClient client = HttpClients.createDefault(); + HttpPost post = new HttpPost(apiUrl); + post.setEntity(entity); + + HttpResponse res = client.execute(post); + + if(res != null){ + BufferedReader in = new BufferedReader(new InputStreamReader(res.getEntity().getContent(), encodingType)); + String buffer = null; + while((buffer = in.readLine())!=null){ + result += buffer; + } + in.close(); + } + out.print(result); + + }catch(Exception e){ + out.print("{\"data\":{\"resultCode\":99,\"msg\":\"WRONG API METHOD\"}}"); + e.printStackTrace(); + } + + /**************** 채널ID 조회 Response 예제 ******************/ + /* "resultCode": 결과코드, "objectList": 채널 목록 */ + /* "msg": 결과 메시지, "profileId": 프로필ID, "senderKey": 발신프로필키 */ + /* "phoneNumber": 핸드폰번호, "yellowId": 채널ID, "categoryName": 카테고리명 */ +%> \ No newline at end of file diff --git a/src/main/webapp/sample_mjon/jsp_example_inqry_templates_detail_form_r1.jsp b/src/main/webapp/sample_mjon/jsp_example_inqry_templates_detail_form_r1.jsp new file mode 100644 index 0000000..7b7a138 --- /dev/null +++ b/src/main/webapp/sample_mjon/jsp_example_inqry_templates_detail_form_r1.jsp @@ -0,0 +1,333 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + + + + + + +
+
+ +
+
+

돌아가기

+
+ +

알림톡 템플릿 상세 조회(샘플-문자온)

+ *bizId와 apiKey값은 실제 서비스시에는 jsp_example_inqry_templates_detail_r1.jsp 파일에 작성하여 사용하세요 +
(샘플 페이지에서는 월활한 테스트를 위해 파라미터 형식으로 제공합니다.) +


+ +
+
+
+ + + +
+
*senderKey (발신프로필키) + +
+
+ + +
+
*templateCode (템플릿코드) + +
+
+ +
+
*mberId (mberId) + +
+
+ + +
+   +
+ +
+
+ + +
+
+ +
+
+ +
+ +
+
\ No newline at end of file diff --git a/src/main/webapp/sample_mjon/jsp_example_inqry_templates_detail_r1.jsp b/src/main/webapp/sample_mjon/jsp_example_inqry_templates_detail_r1.jsp new file mode 100644 index 0000000..0620275 --- /dev/null +++ b/src/main/webapp/sample_mjon/jsp_example_inqry_templates_detail_r1.jsp @@ -0,0 +1,109 @@ +<%@page import="java.io.InputStreamReader"%> +<%@page import="java.io.BufferedReader"%> +<%@page import="org.apache.http.HttpResponse"%> +<%@page import="org.apache.http.client.methods.HttpPost"%> +<%@page import="org.apache.http.impl.client.HttpClients"%> +<%@page import="org.apache.http.client.HttpClient"%> +<%@page import="org.apache.http.HttpEntity"%> +<%@page import="java.net.URLEncoder"%> +<%@page import="org.apache.http.entity.ContentType"%> +<%@page import="java.util.Iterator"%> +<%@page import="java.nio.charset.Charset"%> +<%@page import="org.apache.http.entity.mime.HttpMultipartMode"%> +<%@page import="org.apache.http.entity.mime.MultipartEntityBuilder"%> +<%@page import="java.util.HashMap"%> +<%@page import="java.util.Map"%> +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> +<% + try{ + //기본 설정값 + final String encodingType = "UTF-8"; + final String boundary = "____boundary____"; + + //비즈 아이디, APIKEY - 보안을 위해 실제 서비스 시에는 이곳에 bizId와 apiKey 값을 적어서 사용 + //실제서비스용 + final String accessKey = "3429312e6a2c732188d4cc7d15d8a1baa01d8d91"; //발급받은 api key + + //테스트용 + //String bizId = request.getParameter("p_bizId"); //비즈 아이디 + //String apiKey = request.getParameter("p_apiKey"); //발급받은 api key + + /******************** 전송 요청 URL ********************/ +// final String apiUrl = "http://119.193.215.98:8087/api/kakao/inqry/templates/detail"; //템플릿 상세 조회 API URL + final String apiUrl = "http://localhost:8088/api/kakao/inqry/templates/detail"; //템플릿 상세 조회 API URL + + /******************** 전송 정보 ********************/ + //필수 값 + String p_senderKey = request.getParameter("p_senderKey"); //발신프로필키 + String p_templateCode = request.getParameter("p_templateCode"); //템플릿코드 + String p_mberId = request.getParameter("p_mberId"); //발신프로필키 + + Map params = new HashMap(); + + + System.out.println("accessKey : "+ accessKey); //비즈 아이디 + System.out.println("mberId : "+ p_mberId); //비즈 아이디 + System.out.println("senderKey : "+ p_senderKey); //발신프로필키 + System.out.println("templateCode : "+ p_templateCode); //템플릿코드 + + + //기본 전송 데이터 + params.put("accessKey", accessKey); //비즈 아이디 + params.put("mberId", p_mberId); //비즈 아이디 + params.put("senderKey", p_senderKey); //발신프로필키 + params.put("templateCode", p_templateCode); //템플릿코드 + + //REST API 전송 + String result = ""; + + MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + + builder.setBoundary(boundary); + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + builder.setCharset(Charset.forName(encodingType)); + + try{ + for(Iterator i = params.keySet().iterator(); i.hasNext();){ + String key = i.next(); + //전달값이 없는 경우 오류 + try{ + String value = params.get(key); + if(value != null) { + builder.addTextBody(key, value, ContentType.create("Multipart/related", encodingType)); + } + }catch(Exception ex){ + ex.printStackTrace(); + } + } + }catch(Exception ex){ + ex.printStackTrace(); + } + + HttpEntity entity = builder.build(); + + HttpClient client = HttpClients.createDefault(); + HttpPost post = new HttpPost(apiUrl); + post.setEntity(entity); + + HttpResponse res = client.execute(post); + + if(res != null){ + BufferedReader in = new BufferedReader(new InputStreamReader(res.getEntity().getContent(), encodingType)); + String buffer = null; + while((buffer = in.readLine())!=null){ + result += buffer; + } + in.close(); + } + out.print(result); + + }catch(Exception e){ + out.print("{\"data\":{\"resultCode\":99,\"msg\":\"WRONG API METHOD\"}}"); + e.printStackTrace(); + } + + /**************** 템플릿 상세 조회 Response 예제 ******************/ + /* "resultCode": 결과코드, "objectList": 템플릿 상세 정보 */ + /* "msg": 결과 메시지, "templateCode": 템플릿코드, "templateName": 템플릿명 */ + /* "template": 템플릿 내용, "buttons": 버튼 정보, "quickReplies": 퀵 리플라이 */ +%> \ No newline at end of file diff --git a/src/main/webapp/sample_mjon/jsp_example_inqry_templates_list_form_r1.jsp b/src/main/webapp/sample_mjon/jsp_example_inqry_templates_list_form_r1.jsp new file mode 100644 index 0000000..c4c7464 --- /dev/null +++ b/src/main/webapp/sample_mjon/jsp_example_inqry_templates_list_form_r1.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + + + + +
+
+ +
+
+

돌아가기

+
+ +

알림톡 템플릿 목록 조회(샘플-문자온)

+ *apiKey값은 실제 서비스시에는 jsp_example_inqry_templates_list_r1.jsp 파일에 작성하여 사용하세요 +
(샘플 페이지에서는 월활한 테스트를 위해 파라미터 형식으로 제공합니다.) +


+ +
+
+
+ +
+
*senderKey (발신프로필키) + +
+
*mberId (사용자ID) + +
+
+ + +
+   +
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + +
템플릿코드템플릿명상태생성일자상세조회
+
+ +
+ +
+
\ No newline at end of file diff --git a/src/main/webapp/sample_mjon/jsp_example_inqry_templates_list_r1.jsp b/src/main/webapp/sample_mjon/jsp_example_inqry_templates_list_r1.jsp new file mode 100644 index 0000000..fb66c74 --- /dev/null +++ b/src/main/webapp/sample_mjon/jsp_example_inqry_templates_list_r1.jsp @@ -0,0 +1,102 @@ +<%@page import="java.io.InputStreamReader"%> +<%@page import="java.io.BufferedReader"%> +<%@page import="org.apache.http.HttpResponse"%> +<%@page import="org.apache.http.client.methods.HttpPost"%> +<%@page import="org.apache.http.impl.client.HttpClients"%> +<%@page import="org.apache.http.client.HttpClient"%> +<%@page import="org.apache.http.HttpEntity"%> +<%@page import="java.net.URLEncoder"%> +<%@page import="org.apache.http.entity.ContentType"%> +<%@page import="java.util.Iterator"%> +<%@page import="java.nio.charset.Charset"%> +<%@page import="org.apache.http.entity.mime.HttpMultipartMode"%> +<%@page import="org.apache.http.entity.mime.MultipartEntityBuilder"%> +<%@page import="java.util.HashMap"%> +<%@page import="java.util.Map"%> +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> +<% + try{ + //기본 설정값 + final String encodingType = "UTF-8"; + final String boundary = "____boundary____"; + + //비즈 아이디, APIKEY - 보안을 위해 실제 서비스 시에는 이곳에 bizId와 apiKey 값을 적어서 사용 + //실제서비스용 + final String accessKey = "3429312e6a2c732188d4cc7d15d8a1baa01d8d91"; //발급받은 api key + + //테스트용 + //String bizId = request.getParameter("p_bizId"); //비즈 아이디 + //String apiKey = request.getParameter("p_apiKey"); //발급받은 api key + + /******************** 전송 요청 URL ********************/ +// final String apiUrl = "http://119.193.215.98:8087/api/kakao/inqry/templates/list"; //템플릿 목록 조회 API URL + final String apiUrl = "http://localhost:8088/api/kakao/inqry/templates/list"; //템플릿 목록 조회 API URL + + /******************** 전송 정보 ********************/ + //필수 값 + String p_senderKey = request.getParameter("p_senderKey"); //발신프로필키 + String p_mberId = request.getParameter("p_mberId"); //발신프로필키 + + Map params = new HashMap(); + + System.out.println("accessKey : "+ accessKey); + + //기본 전송 데이터 + params.put("mberId", p_mberId); //비즈 아이디 + params.put("accessKey", accessKey); //인증키 + params.put("senderKey", p_senderKey); //발신프로필키 + + //REST API 전송 + String result = ""; + + MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + + builder.setBoundary(boundary); + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + builder.setCharset(Charset.forName(encodingType)); + + try{ + for(Iterator i = params.keySet().iterator(); i.hasNext();){ + String key = i.next(); + //전달값이 없는 경우 오류 + try{ + String value = params.get(key); + if(value != null) { + builder.addTextBody(key, value, ContentType.create("Multipart/related", encodingType)); + } + }catch(Exception ex){ + ex.printStackTrace(); + } + } + }catch(Exception ex){ + ex.printStackTrace(); + } + + HttpEntity entity = builder.build(); + + HttpClient client = HttpClients.createDefault(); + HttpPost post = new HttpPost(apiUrl); + post.setEntity(entity); + + HttpResponse res = client.execute(post); + + if(res != null){ + BufferedReader in = new BufferedReader(new InputStreamReader(res.getEntity().getContent(), encodingType)); + String buffer = null; + while((buffer = in.readLine())!=null){ + result += buffer; + } + in.close(); + } + out.print(result); + + }catch(Exception e){ + out.print("{\"data\":{\"resultCode\":99,\"msg\":\"WRONG API METHOD\"}}"); + e.printStackTrace(); + } + + /**************** 템플릿 목록 조회 Response 예제 ******************/ + /* "resultCode": 결과코드, "objectList": 템플릿 목록 */ + /* "msg": 결과 메시지, "templateCode": 템플릿코드, "templateName": 템플릿명 */ + /* "templateMessageType": 메시지타입, "status": 상태, "inspectionStatus": 검수상태 */ +%> \ No newline at end of file diff --git a/src/main/webapp/sample_mjon/jsp_example_send_at_form_r1.jsp b/src/main/webapp/sample_mjon/jsp_example_send_at_form_r1.jsp new file mode 100644 index 0000000..6c34fcd --- /dev/null +++ b/src/main/webapp/sample_mjon/jsp_example_send_at_form_r1.jsp @@ -0,0 +1,283 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + + + + 알림톡 발송(샘플-문자온) + + + + + + + +
+
+
+ +
+

돌아가기

+

알림톡 발송(샘플-문자온)

+ *mberId와 accessKey값은 실제 서비스시에는 jsp_example_send_at_r1.jsp 파일에 작성하여 사용하세요.
+ (샘플 페이지에서는 원활한 테스트를 위해 파라미터 형식으로 제공합니다.) +

+
+ + +
+ 알림톡 기본 설정 + + + + + + + + + + + + + + + + + + + + + + + + + +
*senderKey (카카오 알림톡 채널ID)
*templateCode (카카오 알림톡 템플릿 코드)
callFrom (발신번호)
subMsgSendYn (대체문자 전송 여부) + + (Y-전송, N-전송안함) +
테스트여부 + + (기본값 없음, YF-테스트(실패), YS-테스트(성공)) +
+
+ + +
+ 수신자 목록 + +
+ +
+ +
+ +
+ 수신자 1 + + + + + + + + + + + + + + + + + + + + + +
수신자번호
알림톡 내용
알림톡 제목 (선택)
대체문자 본문 (선택)
+
+ +
+
+
+ +
+ +
+
+ + +
+ 발송 결과 + + + + + + + + + +
메세지그룹ID
결과코드
결과메시지
성공수량
실패수량
+
+ +
+
+
+ + diff --git a/src/main/webapp/sample_mjon/jsp_example_send_at_r1.jsp b/src/main/webapp/sample_mjon/jsp_example_send_at_r1.jsp new file mode 100644 index 0000000..56aa620 --- /dev/null +++ b/src/main/webapp/sample_mjon/jsp_example_send_at_r1.jsp @@ -0,0 +1,108 @@ +<%@page import="java.io.InputStreamReader"%> +<%@page import="java.io.BufferedReader"%> +<%@page import="org.apache.http.client.entity.UrlEncodedFormEntity"%> +<%@page import="org.apache.http.client.methods.CloseableHttpResponse"%> +<%@page import="org.apache.http.client.methods.HttpPost"%> +<%@page import="org.apache.http.impl.client.CloseableHttpClient"%> +<%@page import="org.apache.http.impl.client.HttpClients"%> +<%@page import="org.apache.http.message.BasicNameValuePair"%> +<%@page import="org.apache.http.NameValuePair"%> +<%@page import="java.nio.charset.StandardCharsets"%> +<%@page import="java.util.*"%> +<%@ page language="java" contentType="application/json; charset=UTF-8" pageEncoding="UTF-8"%> +<% +response.setCharacterEncoding("UTF-8"); + +try { + // ===== 고정값(실서비스는 서버 보관) ===== + final String MBER_ID = "dudgusw"; + final String API_KEY = "3429312e6a2c732188d4cc7d15d8a1baa01d8d91"; + + // ===== 전송 URL ===== + // final String apiUrl = "http://119.193.215.98:8087/api/kakao/at/sendMsg"; + final String apiUrl = "http://localhost:8088/api/kakao/at/sendMsg"; + + // ===== 공통 파라미터 수신 (p_* / 비접두어 둘 다 허용) ===== + String senderKey = request.getParameter("p_senderKey"); if (senderKey == null) senderKey = request.getParameter("senderKey"); + String templateCode = request.getParameter("p_templateCode"); if (templateCode == null) templateCode = request.getParameter("templateCode"); + String callFrom = request.getParameter("p_callFrom"); if (callFrom == null) callFrom = request.getParameter("callFrom"); + String subMsgSendYn = request.getParameter("p_subMsgSendYn"); if (subMsgSendYn == null) subMsgSendYn = request.getParameter("subMsgSendYn"); + String testYn = request.getParameter("p_testYn"); if (testYn == null) testYn = request.getParameter("testYn"); + + if (callFrom != null) callFrom = callFrom.replaceAll("\\D", ""); // 숫자만 + + // ===== form 구성 (x-www-form-urlencoded) ===== + List form = new ArrayList<>(); + form.add(new BasicNameValuePair("mberId", MBER_ID)); + form.add(new BasicNameValuePair("accessKey", API_KEY)); + form.add(new BasicNameValuePair("senderKey", senderKey != null ? senderKey : "")); + form.add(new BasicNameValuePair("templateCode", templateCode != null ? templateCode : "")); + form.add(new BasicNameValuePair("callFrom", callFrom != null ? callFrom : "")); + form.add(new BasicNameValuePair("subMsgSendYn", subMsgSendYn != null ? subMsgSendYn : "")); + if (testYn != null && !testYn.isEmpty()) { + form.add(new BasicNameValuePair("testYn", testYn)); // snake_case 아님 + } + + // ===== 수신자 인덱스 수집 (callTo_* / p_callTo_* 모두 지원) ===== + Set idxSet = new TreeSet(); // 자동 오름차순 + for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) { + String nm = e.nextElement(); + if (nm.startsWith("callTo_")) { + try { idxSet.add(Integer.parseInt(nm.substring("callTo_".length()))); } catch(Exception ignore){} + } else if (nm.startsWith("p_callTo_")) { + try { idxSet.add(Integer.parseInt(nm.substring("p_callTo_".length()))); } catch(Exception ignore){} + } + } + + // ===== 인덱스별로 Postman 스타일 키 생성해 그대로 추가 ===== + for (Integer idx : idxSet) { + String callTo = request.getParameter("callTo_" + idx); + if (callTo == null) callTo = request.getParameter("p_callTo_" + idx); + if (callTo == null || callTo.trim().isEmpty()) continue; + callTo = callTo.replaceAll("\\D", ""); + + String title = request.getParameter("templateTitle_" + idx); + if (title == null) title = request.getParameter("p_title_" + idx); + + String content = request.getParameter("templateContent_" + idx); + if (content == null) content = request.getParameter("p_msgTxt_" + idx); + + String subTxt = request.getParameter("subMsgTxt_" + idx); + if (subTxt == null) subTxt = request.getParameter("p_subMsgTxt_" + idx); + + form.add(new BasicNameValuePair("callTo_" + idx, callTo)); + if (title != null && !title.isEmpty()) form.add(new BasicNameValuePair("templateTitle_" + idx, title)); + if (content != null && !content.isEmpty()) form.add(new BasicNameValuePair("templateContent_" + idx, content)); + if (subTxt != null && !subTxt.isEmpty()) form.add(new BasicNameValuePair("subMsgTxt_" + idx, subTxt)); + } + + // (선택) 서버 로그로 확인 + System.out.println("form :: " + form); + + // ===== 전송 ===== + String result = ""; + try (CloseableHttpClient client = HttpClients.createDefault()) { + HttpPost post = new HttpPost(apiUrl); + post.setHeader("Accept", "application/json"); + post.setEntity(new UrlEncodedFormEntity(form, StandardCharsets.UTF_8)); + try (CloseableHttpResponse res = client.execute(post)) { + if (res != null && res.getEntity() != null) { + try (BufferedReader in = new BufferedReader( + new InputStreamReader(res.getEntity().getContent(), StandardCharsets.UTF_8))) { + String line; + while ((line = in.readLine()) != null) result += line; + } + } + } + } + System.out.println(" ++ result :: "+ result); + + out.print((result == null || result.isEmpty()) + ? "{\"data\":{\"resultCode\":99,\"msg\":\"EMPTY RESPONSE\"}}" + : result); + +} catch (Exception e) { + out.print("{\"data\":{\"resultCode\":99,\"msg\":\"WRONG API METHOD\"}}"); + e.printStackTrace(); +} +%> diff --git a/src/main/webapp/sample_mjon/jsp_example_send_ft_form_r1.jsp b/src/main/webapp/sample_mjon/jsp_example_send_ft_form_r1.jsp new file mode 100644 index 0000000..0e5977d --- /dev/null +++ b/src/main/webapp/sample_mjon/jsp_example_send_ft_form_r1.jsp @@ -0,0 +1,107 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + + + +친구톡(FT) 발송 샘플 + + + +

친구톡(FT) 발송(샘플)

+ +
+
+ 공통 + + + + + + + + + + + +
*senderKey
adFlag (Y/N)
subMsgSendYn (Y/N)
callFrom
button(JSON) + +
※ WL/AL만 가능
+
templateImage
testYn (YS-성공, YF-실패, 공란-실발송)
+
+ +
+ 수신자 목록 +
+
+ 수신자 1 + + + + + +
callTo_1
templateContent_1
subMsgTxt_1
+
+
+
+
+ +
+
+ +
+ +
+
+ +
+

결과

+

+
+
+
+
diff --git a/src/main/webapp/sample_mjon/jsp_example_send_ft_r1.jsp b/src/main/webapp/sample_mjon/jsp_example_send_ft_r1.jsp
new file mode 100644
index 0000000..9fb70e8
--- /dev/null
+++ b/src/main/webapp/sample_mjon/jsp_example_send_ft_r1.jsp
@@ -0,0 +1,189 @@
+<%@ page language="java" contentType="application/json; charset=UTF-8" pageEncoding="UTF-8"%>
+<%@page import="java.io.*"%>
+<%@page import="java.util.*"%>
+<%@page import="java.nio.charset.StandardCharsets"%>
+
+<%@page import="org.apache.commons.fileupload.FileItem"%>
+<%@page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
+<%@page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
+
+<%@page import="org.apache.http.HttpEntity"%>
+<%@page import="org.apache.http.client.methods.CloseableHttpResponse"%>
+<%@page import="org.apache.http.client.methods.HttpPost"%>
+<%@page import="org.apache.http.entity.ContentType"%>
+<%@page import="org.apache.http.entity.mime.MultipartEntityBuilder"%>
+<%@page import="org.apache.http.entity.mime.HttpMultipartMode"%>
+<%@page import="org.apache.http.impl.client.CloseableHttpClient"%>
+<%@page import="org.apache.http.impl.client.HttpClients"%>
+
+<%
+response.setCharacterEncoding("UTF-8");
+
+try {
+    // ===== 고정값(운영에선 서버 보관) =====
+    final String MBER_ID = "dudgusw";
+    final String API_KEY = "3429312e6a2c732188d4cc7d15d8a1baa01d8d91";
+
+    // final String apiUrl = "http://119.193.215.98:8087/api/kakao/ft/sendMsg";
+    final String apiUrl = "http://localhost:8088/api/kakao/ft/sendMsg";
+
+    // ===== multipart 파싱 (텍스트/파일 모두 수집) =====
+    Map form = new LinkedHashMap<>();
+    FileItem imageItem = null; // templateImage 업로드 파일
+
+    boolean isMp = ServletFileUpload.isMultipartContent(request);
+    if (isMp) {
+        DiskFileItemFactory factory = new DiskFileItemFactory();
+        // (선택) 임시 디스크 디렉터리, 메모리 임계값 등 설정 가능
+        ServletFileUpload upload = new ServletFileUpload(factory);
+        upload.setHeaderEncoding("UTF-8");
+
+        List items = upload.parseRequest(request);
+        for (FileItem it : items) {
+            if (it.isFormField()) {
+                String name = it.getFieldName();
+                String value = it.getString("UTF-8");
+                form.put(name, value);
+            } else {
+                if ("templateImage".equals(it.getFieldName()) && it.getSize() > 0) {
+                    imageItem = it;
+                }
+            }
+        }
+    } else {
+        // x-www-form-urlencoded 등 fallback
+        for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) {
+            String k = e.nextElement();
+            form.put(k, request.getParameter(k));
+        }
+    }
+
+    // ===== 공통 파라미터 추출 (p_* / 비접두어 둘 다 허용) =====
+    String senderKey    = form.get("p_senderKey");    if (senderKey == null)    senderKey    = form.get("senderKey");
+    String adFlag       = form.get("p_adFlag");       if (adFlag == null)       adFlag       = form.get("adFlag");
+    String subMsgSendYn = form.get("p_subMsgSendYn"); if (subMsgSendYn == null) subMsgSendYn = form.get("subMsgSendYn");
+    String callFrom     = form.get("p_callFrom");     if (callFrom == null)     callFrom     = form.get("callFrom");
+    String buttonJson   = form.get("p_button");       if (buttonJson == null)   buttonJson   = form.get("button");
+    String testYn       = form.get("p_testYn");       if (testYn == null)       testYn       = form.get("testYn");
+
+    if (callFrom != null) callFrom = callFrom.replaceAll("\\D", "");
+
+    // ===== 수신자 인덱스 수집 (callTo_* / p_callTo_*) =====
+    Set idxSet = new TreeSet<>();
+    for (String k : form.keySet()) {
+        if (k.startsWith("callTo_")) {
+            try { idxSet.add(Integer.parseInt(k.substring("callTo_".length()))); } catch(Exception ignore){}
+        } else if (k.startsWith("p_callTo_")) {
+            try { idxSet.add(Integer.parseInt(k.substring("p_callTo_".length()))); } catch(Exception ignore){}
+        }
+    }
+
+    // ===== 전송 직전 로그 (요청 최종 데이터 그대로) =====
+    System.out.println("===== [FT SEND] FINAL FIELDS =====");
+    System.out.println("mberId         = " + MBER_ID);
+    System.out.println("accessKey      = " + API_KEY); // 운영에선 마스킹 권장
+    System.out.println("senderKey      = " + senderKey);
+    System.out.println("adFlag         = " + adFlag);
+    System.out.println("subMsgSendYn   = " + subMsgSendYn);
+    System.out.println("callFrom       = " + callFrom);
+    System.out.println("button         = " + buttonJson);
+    System.out.println("testYn         = " + testYn);
+
+    for (Integer i : idxSet) {
+        String callTo  = form.get("callTo_" + i);     if (callTo == null)  callTo  = form.get("p_callTo_" + i);
+        String content = form.get("templateContent_" + i); if (content == null) content = form.get("p_templateContent_" + i);
+        String subTxt  = form.get("subMsgTxt_" + i);  if (subTxt == null)  subTxt  = form.get("p_subMsgTxt_" + i);
+
+        System.out.println("--- Receiver #" + i + " ---");
+        System.out.println("callTo_" + i + "          = " + callTo);
+        System.out.println("templateContent_" + i + " = " + content);
+        System.out.println("subMsgTxt_" + i + "       = " + subTxt);
+    }
+
+    String imageLog = "none";
+    if (imageItem != null) {
+        imageLog = "[upload] name=" + imageItem.getName() + ", size=" + imageItem.getSize();
+    } else {
+        String imagePath = form.get("templateImagePath");
+        if (imagePath != null && !imagePath.isEmpty()) {
+            File f = new File(imagePath);
+            if (f.exists() && f.isFile()) {
+                imageLog = "[path] " + f.getAbsolutePath() + " (size=" + f.length() + ")";
+            }
+        }
+    }
+    System.out.println("templateImage  = " + imageLog);
+    System.out.println("===================================");
+
+    // ===== 원 API로 멀티파트 전송 =====
+    MultipartEntityBuilder mb = MultipartEntityBuilder.create()
+        .setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
+        .setCharset(StandardCharsets.UTF_8);
+
+    ContentType TEXT = ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8);
+
+    // 공통
+    mb.addTextBody("mberId",    MBER_ID, TEXT);
+    mb.addTextBody("accessKey", API_KEY, TEXT);
+    if (senderKey    != null) mb.addTextBody("senderKey",    senderKey, TEXT);
+    if (adFlag       != null) mb.addTextBody("adFlag",       adFlag, TEXT);
+    if (subMsgSendYn != null) mb.addTextBody("subMsgSendYn", subMsgSendYn, TEXT);
+    if (callFrom     != null) mb.addTextBody("callFrom",     callFrom, TEXT);
+    if (buttonJson != null && !buttonJson.isEmpty()) mb.addTextBody("button", buttonJson, TEXT);
+    if (testYn     != null && !testYn.isEmpty())     mb.addTextBody("testYn", testYn, TEXT);
+
+    // 수신자
+    for (Integer i : idxSet) {
+        String callTo  = form.get("callTo_" + i);     if (callTo == null)  callTo  = form.get("p_callTo_" + i);
+        String content = form.get("templateContent_" + i); if (content == null) content = form.get("p_templateContent_" + i);
+        String subTxt  = form.get("subMsgTxt_" + i);  if (subTxt == null)  subTxt  = form.get("p_subMsgTxt_" + i);
+
+        if (callTo == null || callTo.trim().isEmpty()) continue;
+        callTo = callTo.replaceAll("\\D","");
+
+        mb.addTextBody("callTo_" + i, callTo, TEXT);
+        if (content != null && !content.isEmpty()) mb.addTextBody("templateContent_" + i, content, TEXT);
+        if (subTxt  != null && !subTxt.isEmpty())  mb.addTextBody("subMsgTxt_" + i,       subTxt, TEXT);
+    }
+
+    // 이미지
+    if (imageItem != null) {
+        mb.addBinaryBody("templateImage", imageItem.getInputStream(),
+                ContentType.DEFAULT_BINARY, imageItem.getName());
+    } else {
+        String imagePath = form.get("templateImagePath");
+        if (imagePath != null && !imagePath.isEmpty()) {
+            File f = new File(imagePath);
+            if (f.exists() && f.isFile()) {
+                mb.addBinaryBody("templateImage", f, ContentType.DEFAULT_BINARY, f.getName());
+            }
+        }
+    }
+
+    HttpEntity entity = mb.build();
+
+    String result = "";
+    try (CloseableHttpClient client = HttpClients.createDefault()) {
+        HttpPost post = new HttpPost(apiUrl);
+        post.setHeader("Accept", "application/json");
+        post.setEntity(entity);
+        try (CloseableHttpResponse res = client.execute(post)) {
+            if (res != null && res.getEntity() != null) {
+                try (BufferedReader br = new BufferedReader(
+                        new InputStreamReader(res.getEntity().getContent(), StandardCharsets.UTF_8))) {
+                    String line;
+                    while ((line = br.readLine()) != null) result += line;
+                }
+            }
+        }
+    }
+
+    out.print((result == null || result.isEmpty())
+        ? "{\"data\":{\"resultCode\":99,\"msg\":\"EMPTY RESPONSE\"}}"
+        : result);
+
+} catch (Exception e) {
+    out.print("{\"data\":{\"resultCode\":99,\"msg\":\"WRONG API METHOD\"}}");
+    e.printStackTrace();
+}
+%>
diff --git a/src/main/webapp/sample_mjon/jsp_example_send_msg_r1.jsp b/src/main/webapp/sample_mjon/jsp_example_send_msg_r1.jsp
index 0660274..5120c05 100644
--- a/src/main/webapp/sample_mjon/jsp_example_send_msg_r1.jsp
+++ b/src/main/webapp/sample_mjon/jsp_example_send_msg_r1.jsp
@@ -34,8 +34,8 @@
 
 		/******************** 전송 요청 URL  ********************/
 // 		final String apiUrl		=	"https://api.munjaon.co.kr/api/send/sendMsg";	//개발테스트용 URL
-// 		final String apiUrl		=	"http://localhost:8088/api/send/sendMsg";	//개발테스트용 URL URL
-        final String apiUrl     =   "http://119.193.215.98:8087/api/send/sendMsg";   //개발테스트용 URL
+		String apiUrl		=	"/api/send/sendMsg";	//개발테스트용 URL URL
+//         final String apiUrl     =   "http://119.193.215.98:8087/api/send/sendMsg";   //개발테스트용 URL
 		
 		/******************** 전송 정보 ********************/
 		//필수 값
@@ -46,6 +46,8 @@
 		//선택 값
 		String p_nameStr	= request.getParameter("p_nameStr");	//치환용 이름 
 		String p_testYn		= request.getParameter("p_testYn");		//테스트 데이터 여부 '', 'YF', 'YS'
+		String p_api_ip		= request.getParameter("p_api_ip");		//테스트 데이터 여부 '', 'YF', 'YS'
+		apiUrl += p_api_ip;
 		
 		/* 추후 사용을 위하여 주석 상태로 보존 - 사용자 샘플 JSP에는 해당 내용 삭제 */ 
 		
diff --git a/src/main/webapp/sample_mjon/jsp_example_start_form_r1.jsp b/src/main/webapp/sample_mjon/jsp_example_start_form_r1.jsp
index 3408887..496c48e 100644
--- a/src/main/webapp/sample_mjon/jsp_example_start_form_r1.jsp
+++ b/src/main/webapp/sample_mjon/jsp_example_start_form_r1.jsp
@@ -15,6 +15,14 @@
 				

3.전체발송내역

4.상세발송내역

5.발송가능건수

+
+ +

6.알림톡 발송

+

7.친구톡 발송

+
+ +

8.알림톡 채널ID 조회

+

9.알림톡 템플릿 목록 조회

diff --git a/src/main/webapp/sample_mjon/jsp_example_start_form_r1_backup.jsp b/src/main/webapp/sample_mjon/jsp_example_start_form_r1_backup.jsp new file mode 100644 index 0000000..3408887 --- /dev/null +++ b/src/main/webapp/sample_mjon/jsp_example_start_form_r1_backup.jsp @@ -0,0 +1,23 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + +
+
+ + +
+
+