Compare commits
7 Commits
5145_apite
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6df56b7b7 | ||
|
|
8b8da221b3 | ||
|
|
33b8b281bc | ||
|
|
84ff0a6186 | ||
| 529dfd194e | |||
|
|
41ba6092c4 | ||
|
|
54a14cd2de |
@ -2681,7 +2681,7 @@
|
|||||||
|
|
||||||
<isNotEmpty property="searchCondition3" prepend="AND">
|
<isNotEmpty property="searchCondition3" prepend="AND">
|
||||||
<isEqual property="searchCondition3" compareValue="10">
|
<isEqual property="searchCondition3" compareValue="10">
|
||||||
MMGD.SEND_KIND ='H'
|
(MMGD.SEND_KIND = 'H' or MMGD.SEND_KIND is null)
|
||||||
</isEqual>
|
</isEqual>
|
||||||
<isEqual property="searchCondition3" compareValue="20">
|
<isEqual property="searchCondition3" compareValue="20">
|
||||||
MMGD.SEND_KIND ='A'
|
MMGD.SEND_KIND ='A'
|
||||||
@ -2781,8 +2781,19 @@
|
|||||||
<isEqual property="searchCondition" compareValue="3">
|
<isEqual property="searchCondition" compareValue="3">
|
||||||
AND MMGD.SMS_TXT LIKE CONCAT ('%', #searchKeyword#,'%')
|
AND MMGD.SMS_TXT LIKE CONCAT ('%', #searchKeyword#,'%')
|
||||||
</isEqual>
|
</isEqual>
|
||||||
</isNotEmpty>
|
</isNotEmpty>
|
||||||
|
|
||||||
|
<isNotEmpty property="searchCondition3" prepend="AND">
|
||||||
|
<isEqual property="searchCondition3" compareValue="10">
|
||||||
|
(MMGD.SEND_KIND = 'H' or MMGD.SEND_KIND is null)
|
||||||
|
</isEqual>
|
||||||
|
<isEqual property="searchCondition3" compareValue="20">
|
||||||
|
MMGD.SEND_KIND ='A'
|
||||||
|
</isEqual>
|
||||||
|
</isNotEmpty>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<select id="mjonKakaoATDAO.selectMjonKakaoATGroupCompleteByUserList_advc_back" parameterClass="kakaoVO" resultClass="kakaoVO">
|
<select id="mjonKakaoATDAO.selectMjonKakaoATGroupCompleteByUserList_advc_back" parameterClass="kakaoVO" resultClass="kakaoVO">
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
@ -1508,7 +1508,8 @@
|
|||||||
MRC.RESULT_CODE AS resultCode, /** 문자 결과 코드 정보*/
|
MRC.RESULT_CODE AS resultCode, /** 문자 결과 코드 정보*/
|
||||||
MRC.RESULT_CODE2 AS resultCode2, /** 문자 결과 코드 정보*/
|
MRC.RESULT_CODE2 AS resultCode2, /** 문자 결과 코드 정보*/
|
||||||
MGD.MSG_KIND AS msgKind, /** 문자 종류 -일반, 광고, 선거문자*/
|
MGD.MSG_KIND AS msgKind, /** 문자 종류 -일반, 광고, 선거문자*/
|
||||||
MGD.MSG_GROUP_ID AS msgGroupId
|
MGD.MSG_GROUP_ID AS msgGroupId,
|
||||||
|
MGD.SEND_KIND as sendKind
|
||||||
FROM MJ_MSG_DATA A
|
FROM MJ_MSG_DATA A
|
||||||
LEFT JOIN MJ_MSG_GROUP_DATA MGD
|
LEFT JOIN MJ_MSG_GROUP_DATA MGD
|
||||||
ON A.MSG_GROUP_ID = MGD.MSG_GROUP_ID
|
ON A.MSG_GROUP_ID = MGD.MSG_GROUP_ID
|
||||||
@ -8272,6 +8273,7 @@
|
|||||||
|
|
||||||
<!-- 문자발송 완료건은 모두 보이도록 처리 -->
|
<!-- 문자발송 완료건은 모두 보이도록 처리 -->
|
||||||
<select id="mjonMsgDAO.selectMjonMsgGroupCompleteList_advc" parameterClass="mjonMsgVO" resultClass="mjonMsgVO">
|
<select id="mjonMsgDAO.selectMjonMsgGroupCompleteList_advc" parameterClass="mjonMsgVO" resultClass="mjonMsgVO">
|
||||||
|
/* mjonMsgDAO.selectMjonMsgGroupCompleteList_advc */
|
||||||
SELECT
|
SELECT
|
||||||
M.totCnt
|
M.totCnt
|
||||||
, M.msgGroupId
|
, M.msgGroupId
|
||||||
@ -8461,12 +8463,12 @@
|
|||||||
THEN (REQ_DATE <= NOW() OR (IFNULL(DELAY_YN, 'N') = 'Y' AND IFNULL(DELAY_COMPLETE_YN, 'N') = 'N'))
|
THEN (REQ_DATE <= NOW() OR (IFNULL(DELAY_YN, 'N') = 'Y' AND IFNULL(DELAY_COMPLETE_YN, 'N') = 'N'))
|
||||||
END
|
END
|
||||||
]]>
|
]]>
|
||||||
<isNotEmpty property="sendKind">
|
<isNotEmpty property="sendKind" prepend="AND">
|
||||||
<isEqual property="sendKind" compareValue="H">
|
<isEqual property="sendKind" compareValue="H">
|
||||||
AND A.SEND_KIND = 'H'
|
(A.SEND_KIND = 'H' or A.SEND_KIND is null)
|
||||||
</isEqual>
|
</isEqual>
|
||||||
<isEqual property="sendKind" compareValue="A">
|
<isEqual property="sendKind" compareValue="A">
|
||||||
AND A.SEND_KIND = 'A'
|
A.SEND_KIND = 'A'
|
||||||
</isEqual>
|
</isEqual>
|
||||||
</isNotEmpty>
|
</isNotEmpty>
|
||||||
<isNotEmpty property="searchKeyword">
|
<isNotEmpty property="searchKeyword">
|
||||||
|
|||||||
@ -1491,7 +1491,8 @@
|
|||||||
) F
|
) F
|
||||||
ON A.MOID = F.MOID
|
ON A.MOID = F.MOID
|
||||||
WHERE 1=1
|
WHERE 1=1
|
||||||
AND A.USER_ID LIKE CONCAT('%', #searchKeyword#, '%')
|
/* AND A.USER_ID LIKE CONCAT('%', #searchKeyword#, '%') */
|
||||||
|
AND A.USER_ID = #searchKeyword#
|
||||||
ORDER BY 1=1 ,
|
ORDER BY 1=1 ,
|
||||||
moid desc
|
moid desc
|
||||||
LIMIT #recordCountPerPage# OFFSET #firstIndex#
|
LIMIT #recordCountPerPage# OFFSET #firstIndex#
|
||||||
|
|||||||
@ -897,9 +897,9 @@ function fn_SpamMberUpdt(userId, p_mberSttus, p_smiMemo, p_confirm_msg, p_msgGro
|
|||||||
<c:when test="${result.sendKind eq 'A'}">
|
<c:when test="${result.sendKind eq 'A'}">
|
||||||
API
|
API
|
||||||
</c:when>
|
</c:when>
|
||||||
<c:when test="${result.sendKind eq 'H'}">
|
<c:otherwise>
|
||||||
WEB
|
WEB
|
||||||
</c:when>
|
</c:otherwise>
|
||||||
</c:choose>
|
</c:choose>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@ -385,15 +385,31 @@ function fnSelectMber(mberId) {
|
|||||||
<c:when test="${mjonMsgVO.msgKind eq 'A'}">
|
<c:when test="${mjonMsgVO.msgKind eq 'A'}">
|
||||||
광고문자
|
광고문자
|
||||||
</c:when>
|
</c:when>
|
||||||
<c:when test="${mjonMsgVO.msgKind eq 'C'}">
|
<c:when test="${mjonMsgVO.msgKind eq 'C'}">
|
||||||
선거문자
|
선거문자
|
||||||
</c:when>
|
</c:when>
|
||||||
|
<c:when test="${mjonMsgVO.msgKind eq 'S'}">
|
||||||
|
관리자 발송
|
||||||
|
</c:when>
|
||||||
<c:otherwise>
|
<c:otherwise>
|
||||||
관리자 발송
|
일반문자
|
||||||
</c:otherwise>
|
</c:otherwise>
|
||||||
</c:choose>
|
</c:choose>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<%-- <tr class="no_modi">
|
||||||
|
<th>방식</th>
|
||||||
|
<td colspan="3">
|
||||||
|
<c:choose>
|
||||||
|
<c:when test="${mjonMsgVO.sendKind eq 'A'}">
|
||||||
|
API
|
||||||
|
</c:when>
|
||||||
|
<c:otherwise>
|
||||||
|
WEB
|
||||||
|
</c:otherwise>
|
||||||
|
</c:choose>
|
||||||
|
</td>
|
||||||
|
</tr>--%>
|
||||||
<%--
|
<%--
|
||||||
<tr>
|
<tr>
|
||||||
<th><span class="reqArea">제목</span></th>
|
<th><span class="reqArea">제목</span></th>
|
||||||
|
|||||||
@ -15,95 +15,87 @@
|
|||||||
<%@page import="java.util.Map"%>
|
<%@page import="java.util.Map"%>
|
||||||
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
|
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
|
||||||
<%
|
<%
|
||||||
try{
|
try{
|
||||||
//기본 설정값
|
//기본 설정값
|
||||||
final String encodingType = "UTF-8";
|
final String encodingType = "UTF-8";
|
||||||
final String boundary = "____boundary____";
|
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 ********************/
|
|
||||||
|
//비즈 아이디, APIKEY - 보안을 위해 실제 서비스 시에는 이곳에 bizId와 apiKey 값을 적어서 사용
|
||||||
|
//실제서비스용
|
||||||
|
final String accessKey = "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/templates/detail"; //템플릿 상세 조회 API 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<String, String> params = new HashMap<String, String>();
|
|
||||||
|
|
||||||
|
|
||||||
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<String> 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();
|
//회원아이디, APIKEY - 보안을 위해 실제 서비스 시에는 이곳에 mberId와 apiKey 값을 적어서 사용
|
||||||
|
String p_senderKey = request.getParameter("p_senderKey"); //발신프로필키
|
||||||
HttpClient client = HttpClients.createDefault();
|
String p_templateCode = request.getParameter("p_templateCode"); //템플릿코드
|
||||||
HttpPost post = new HttpPost(apiUrl);
|
String p_mberId = request.getParameter("p_mberId"); //발신프로필키
|
||||||
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 예제 ******************/
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
/* "resultCode": 결과코드, "objectList": 템플릿 상세 정보 */
|
|
||||||
/* "msg": 결과 메시지, "templateCode": 템플릿코드, "templateName": 템플릿명 */
|
//기본 전송 데이터
|
||||||
/* "template": 템플릿 내용, "buttons": 버튼 정보, "quickReplies": 퀵 리플라이 */
|
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<String> 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": 카테고리명 */
|
||||||
%>
|
%>
|
||||||
@ -15,88 +15,86 @@
|
|||||||
<%@page import="java.util.Map"%>
|
<%@page import="java.util.Map"%>
|
||||||
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
|
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
|
||||||
<%
|
<%
|
||||||
try{
|
try{
|
||||||
//기본 설정값
|
//기본 설정값
|
||||||
final String encodingType = "UTF-8";
|
final String encodingType = "UTF-8";
|
||||||
final String boundary = "____boundary____";
|
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 ********************/
|
|
||||||
|
//비즈 아이디, APIKEY - 보안을 위해 실제 서비스 시에는 이곳에 bizId와 apiKey 값을 적어서 사용
|
||||||
|
//실제서비스용
|
||||||
|
final String accessKey = "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/templates/list"; //템플릿 목록 조회 API 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
|
// 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<String, String> params = new HashMap<String, String>();
|
|
||||||
|
|
||||||
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<String> 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 예제 ******************/
|
//회원아이디, APIKEY - 보안을 위해 실제 서비스 시에는 이곳에 mberId와 apiKey 값을 적어서 사용
|
||||||
/* "resultCode": 결과코드, "objectList": 템플릿 목록 */
|
String p_senderKey = request.getParameter("p_senderKey"); //발신자 번호
|
||||||
/* "msg": 결과 메시지, "templateCode": 템플릿코드, "templateName": 템플릿명 */
|
String p_mberId = request.getParameter("p_mberId"); //수신자 번호
|
||||||
/* "templateMessageType": 메시지타입, "status": 상태, "inspectionStatus": 검수상태 */
|
|
||||||
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
|
|
||||||
|
//기본 전송 데이터
|
||||||
|
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<String> 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": 카테고리명 */
|
||||||
%>
|
%>
|
||||||
@ -1,116 +1,160 @@
|
|||||||
<%@page import="java.io.InputStreamReader"%>
|
<%@page import="java.io.InputStreamReader"%>
|
||||||
<%@page import="java.io.BufferedReader"%>
|
<%@page import="java.io.BufferedReader"%>
|
||||||
<%@page import="org.apache.http.client.entity.UrlEncodedFormEntity"%>
|
<%@page import="org.apache.http.HttpResponse"%>
|
||||||
<%@page import="org.apache.http.client.methods.CloseableHttpResponse"%>
|
|
||||||
<%@page import="org.apache.http.client.methods.HttpPost"%>
|
<%@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.impl.client.HttpClients"%>
|
||||||
<%@page import="org.apache.http.message.BasicNameValuePair"%>
|
<%@page import="org.apache.http.client.HttpClient"%>
|
||||||
<%@page import="org.apache.http.NameValuePair"%>
|
<%@page import="org.apache.http.HttpEntity"%>
|
||||||
<%@page import="java.nio.charset.StandardCharsets"%>
|
<%@page import="java.net.URLEncoder"%>
|
||||||
<%@page import="java.util.*"%>
|
<%@page import="org.apache.http.entity.ContentType"%>
|
||||||
<%@ page language="java" contentType="application/json; charset=UTF-8" pageEncoding="UTF-8"%>
|
<%@page import="java.nio.charset.Charset"%>
|
||||||
|
<%@page import="org.apache.http.entity.mime.HttpMultipartMode"%>
|
||||||
|
<%@page import="org.apache.http.entity.mime.MultipartEntityBuilder"%>
|
||||||
|
<%@ page import="org.apache.http.message.BasicNameValuePair" %>
|
||||||
|
<%@page import="org.apache.http.entity.StringEntity"%>
|
||||||
|
<%@page import="org.apache.http.entity.ContentType"%>
|
||||||
|
<%@page import="java.net.URLEncoder"%>
|
||||||
|
<%@ page import="java.util.*" %>
|
||||||
|
<%@ page import="org.apache.http.impl.client.CloseableHttpClient" %>
|
||||||
|
<%@ page import="java.nio.charset.StandardCharsets" %>
|
||||||
|
<%@ page import="org.apache.http.client.entity.UrlEncodedFormEntity" %>
|
||||||
|
<%@ page import="org.apache.http.client.methods.CloseableHttpResponse" %>
|
||||||
|
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
|
||||||
<%
|
<%
|
||||||
response.setCharacterEncoding("UTF-8");
|
try{
|
||||||
|
//기본 설정값
|
||||||
try {
|
final String encodingType = "UTF-8";
|
||||||
// ===== 고정값(실서비스는 서버 보관) =====
|
final String boundary = "____boundary____";
|
||||||
|
|
||||||
// ===== 전송 URL =====
|
|
||||||
// final String apiUrl = "http://119.193.215.98:8087/api/kakao/at/sendMsg";
|
|
||||||
final String apiUrl = "http://119.193.215.98:8087/api/kakao/at/sendMsg";
|
|
||||||
// final String apiUrl = "http://localhost:8088/api/kakao/at/sendMsg";
|
|
||||||
|
|
||||||
|
|
||||||
String p_mberId = request.getParameter("mberId"); //사용자 ID
|
//테스트용
|
||||||
String p_apiKey = request.getParameter("accessKey"); //API KEY
|
//String mberId = request.getParameter("p_mberId"); //문자온 로그인 아이디
|
||||||
|
//String apiKey = request.getParameter("p_apiKey"); //발급받은 api key
|
||||||
System.out.println("p_mberId : "+ p_mberId);
|
|
||||||
System.out.println("p_apiKey : "+ p_apiKey);
|
|
||||||
|
|
||||||
// ===== 공통 파라미터 수신 (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");
|
|
||||||
|
|
||||||
System.out.println("senderKey : "+ senderKey);
|
/******************** 전송 요청 URL ********************/
|
||||||
|
final String apiUrl = "http://119.193.215.98:8087/api/kakao/at/sendMsg";
|
||||||
|
|
||||||
if (callFrom != null) callFrom = callFrom.replaceAll("\\D", ""); // 숫자만
|
|
||||||
|
|
||||||
// ===== form 구성 (x-www-form-urlencoded) =====
|
//회원아이디, APIKEY - 보안을 위해 실제 서비스 시에는 이곳에 mberId와 apiKey 값을 적어서 사용
|
||||||
List<NameValuePair> form = new ArrayList<>();
|
String p_mberId = request.getParameter("mberId"); //사용자 ID
|
||||||
form.add(new BasicNameValuePair("mberId", p_mberId));
|
String p_apiKey = request.getParameter("accessKey"); //API KEY
|
||||||
form.add(new BasicNameValuePair("accessKey", p_apiKey));
|
|
||||||
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_* 모두 지원) =====
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
Set<Integer> idxSet = new TreeSet<Integer>(); // 자동 오름차순
|
|
||||||
for (Enumeration<String> e = request.getParameterNames(); e.hasMoreElements();) {
|
//기본 전송 데이터
|
||||||
String nm = e.nextElement();
|
params.put("mberId", p_mberId); //회원 아이디
|
||||||
if (nm.startsWith("callTo_")) {
|
params.put("accessKey", p_apiKey); //인증키
|
||||||
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){}
|
// ===== 공통 파라미터 수신 (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", ""); // 숫자만
|
||||||
|
|
||||||
|
Map<String, String> form = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
|
form.put("mberId", p_mberId);
|
||||||
|
form.put("accessKey", p_apiKey);
|
||||||
|
form.put("senderKey", senderKey != null ? senderKey : "");
|
||||||
|
form.put("templateCode", templateCode != null ? templateCode : "");
|
||||||
|
form.put("callFrom", callFrom != null ? callFrom : "");
|
||||||
|
form.put("subMsgSendYn", subMsgSendYn != null ? subMsgSendYn : "");
|
||||||
|
|
||||||
|
if (testYn != null && !testYn.isEmpty()) {
|
||||||
|
form.put("testYn", testYn);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// ===== 인덱스별로 Postman 스타일 키 생성해 그대로 추가 =====
|
// ===== 수신자 인덱스 수집 (callTo_* / p_callTo_* 모두 지원) =====
|
||||||
for (Integer idx : idxSet) {
|
Set<Integer> idxSet = new TreeSet<Integer>(); // 자동 오름차순
|
||||||
String callTo = request.getParameter("callTo_" + idx);
|
for (Enumeration<String> e = request.getParameterNames(); e.hasMoreElements();) {
|
||||||
if (callTo == null) callTo = request.getParameter("p_callTo_" + idx);
|
String nm = e.nextElement();
|
||||||
if (callTo == null || callTo.trim().isEmpty()) continue;
|
if (nm.startsWith("callTo_")) {
|
||||||
callTo = callTo.replaceAll("\\D", "");
|
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){}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String title = request.getParameter("templateTitle_" + idx);
|
// ===== 인덱스별로 Postman 스타일 키 생성해 그대로 추가 =====
|
||||||
if (title == null) title = request.getParameter("p_title_" + idx);
|
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 content = request.getParameter("templateContent_" + idx);
|
String title = request.getParameter("templateTitle_" + idx);
|
||||||
if (content == null) content = request.getParameter("p_msgTxt_" + idx);
|
if (title == null) title = request.getParameter("p_title_" + idx);
|
||||||
|
|
||||||
String subTxt = request.getParameter("subMsgTxt_" + idx);
|
String content = request.getParameter("templateContent_" + idx);
|
||||||
if (subTxt == null) subTxt = request.getParameter("p_subMsgTxt_" + idx);
|
if (content == null) content = request.getParameter("p_msgTxt_" + idx);
|
||||||
|
|
||||||
form.add(new BasicNameValuePair("callTo_" + idx, callTo));
|
String subTxt = request.getParameter("subMsgTxt_" + idx);
|
||||||
if (title != null && !title.isEmpty()) form.add(new BasicNameValuePair("templateTitle_" + idx, title));
|
if (subTxt == null) subTxt = request.getParameter("p_subMsgTxt_" + idx);
|
||||||
if (content != null && !content.isEmpty()) form.add(new BasicNameValuePair("templateContent_" + idx, content));
|
form.put("callTo_" + idx, callTo);
|
||||||
if (subTxt != null && !subTxt.isEmpty()) form.add(new BasicNameValuePair("subMsgTxt_" + idx, subTxt));
|
if (title != null && !title.isEmpty()) form.put("templateTitle_" + idx, title);
|
||||||
}
|
if (content != null && !content.isEmpty()) form.put("templateContent_" + idx, content);
|
||||||
|
if (subTxt != null && !subTxt.isEmpty()) form.put("subMsgTxt_" + idx, subTxt);
|
||||||
|
|
||||||
// (선택) 서버 로그로 확인
|
}
|
||||||
System.out.println("form :: " + form);
|
|
||||||
|
|
||||||
// ===== 전송 =====
|
|
||||||
String result = "";
|
|
||||||
try (CloseableHttpClient client = HttpClients.createDefault()) {
|
// ===== 전송 =====
|
||||||
HttpPost post = new HttpPost(apiUrl);
|
String result = "";
|
||||||
post.setHeader("Accept", "application/json");
|
try (CloseableHttpClient client = HttpClients.createDefault()) {
|
||||||
post.setEntity(new UrlEncodedFormEntity(form, StandardCharsets.UTF_8));
|
|
||||||
try (CloseableHttpResponse res = client.execute(post)) {
|
HttpPost post = new HttpPost(apiUrl);
|
||||||
if (res != null && res.getEntity() != null) {
|
post.setHeader("Accept", "application/json");
|
||||||
try (BufferedReader in = new BufferedReader(
|
|
||||||
new InputStreamReader(res.getEntity().getContent(), StandardCharsets.UTF_8))) {
|
// form(Map)을 x-www-form-urlencoded 문자열로 변환
|
||||||
String line;
|
StringBuilder body = new StringBuilder();
|
||||||
while ((line = in.readLine()) != null) result += line;
|
for (Map.Entry<String, String> entry : form.entrySet()) {
|
||||||
|
if (body.length() > 0) {
|
||||||
|
body.append('&');
|
||||||
|
}
|
||||||
|
body.append(URLEncoder.encode(entry.getKey(), "UTF-8"))
|
||||||
|
.append('=')
|
||||||
|
.append(URLEncoder.encode(entry.getValue() != null ? entry.getValue() : "", "UTF-8"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// StringEntity로 설정
|
||||||
|
StringEntity entity = new StringEntity(
|
||||||
|
body.toString(),
|
||||||
|
ContentType.APPLICATION_FORM_URLENCODED.withCharset(StandardCharsets.UTF_8)
|
||||||
|
);
|
||||||
|
post.setEntity(entity);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
System.out.println(" ++ result :: "+ result);
|
|
||||||
|
|
||||||
out.print((result == null || result.isEmpty())
|
/**************** 채널ID 조회 Response 예제 ******************/
|
||||||
? "{\"data\":{\"resultCode\":99,\"msg\":\"EMPTY RESPONSE\"}}"
|
/* "resultCode": 결과코드, "objectList": 채널 목록 */
|
||||||
: result);
|
/* "msg": 결과 메시지, "profileId": 프로필ID, "senderKey": 발신프로필키 */
|
||||||
|
/* "phoneNumber": 핸드폰번호, "yellowId": 채널ID, "categoryName": 카테고리명 */
|
||||||
} catch (Exception e) {
|
%>
|
||||||
out.print("{\"data\":{\"resultCode\":99,\"msg\":\"WRONG API METHOD\"}}");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<hr style="margin: 20px 0;">
|
<hr style="margin: 20px 0;">
|
||||||
<!-- 카카오톡 메시지 메뉴 -->
|
<!-- 카카오톡 메시지 메뉴 -->
|
||||||
<h2><a href="./jsp_example_send_at_form_r1.jsp">6.알림톡 발송</a></h2>
|
<h2><a href="./jsp_example_send_at_form_r1.jsp">6.알림톡 발송</a></h2>
|
||||||
<h2><a href="./jsp_example_send_ft_form_r1.jsp">7.친구톡 발송</a></h2>
|
<%-- <h2><a href="./jsp_example_send_ft_form_r1.jsp">7.친구톡 발송</a></h2>--%>
|
||||||
<hr style="margin: 20px 0;">
|
<hr style="margin: 20px 0;">
|
||||||
<!-- 조회 메뉴 -->
|
<!-- 조회 메뉴 -->
|
||||||
<h2><a href="./jsp_example_inqry_chnlid_form_r1.jsp">8.알림톡 채널ID 조회</a></h2>
|
<h2><a href="./jsp_example_inqry_chnlid_form_r1.jsp">8.알림톡 채널ID 조회</a></h2>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user