jiwoo 2023-06-19
이지우 - REST API 샘플 소스 이쁘게 정리^^
@8e6ec61d18e1fff3ec3a5d44fea824b766384057
src/main/webapp/sample_mjon/jsp_example_send_msg_form_r1.jsp
--- src/main/webapp/sample_mjon/jsp_example_send_msg_form_r1.jsp
+++ src/main/webapp/sample_mjon/jsp_example_send_msg_form_r1.jsp
@@ -2,141 +2,75 @@
 <script type="text/javascript" src="./jquery-3.5.0.js"></script>
 
  	<script type="text/javascript">
-			  $(document).ready(function(){
-
-				//문자발송
-				$("#ajax_select_price").click(function(){
-
-					$("span#mgi").text("");
-					$("span#sc").text("");
-					$("span#fc").text("");
-					$("span#bc").text("");
-					$("span#mt").text("");
+		$(document).ready(function(){
+	
+			//문자발송 함수
+			$("#ajax_select_price").click(function(){
+		
+				//문자발송 결과 데이터 수신 전 기존 데이터 초기화
+				$("span#mgi").text("");
+				$("span#sc").text("");
+				$("span#fc").text("");
+				$("span#bc").text("");
+				$("span#mt").text("");
+									
+				//문자발송 API로 전송할 데이터
+				var searchWebParam = {
+					'p_mberId'			: $('#mberId').val()	//회원 아이디
+					, 'p_apiKey'		: $('#apiKey').val()	//api 키 
+					, 'p_callFrom'		: $('#callFrom').val()	//발신자 번호
+					, 'p_callToList'	: $('#callToList').val()//수신자 번호
+					, 'p_smsTxt'		: $('#smsTxt').val()	//문자 내용
+					, 'p_nameStr'		: $('#nameStr').val()	//치환용 이름
+					, 'p_testYn'		: $('#testYn').val()	//테스트 데이터 여부
+				};
 										
-					//document.updatePasswordForm.action = '/web/user/sendRESTAPI_test_r1_send.do';
-					//document.updatePasswordForm.submit();
-
-						var searchWebParam = {
-			     				'p_mberId'			: $('#mberId').val() 
-			     				, 'p_apiKey'		: $('#apiKey').val()
-			     				, 'p_callFrom'		: $('#callFrom').val()
-			     				, 'p_callToList'	: $('#callToList').val()
-			     				, 'p_smsTxt'		: $('#smsTxt').val()
-			     				, 'p_nameStr'		: $('#nameStr').val()
-			     				, 'p_testYn'		: $('#testYn').val()
-			     				//, 'p_eachPrice'		: $('#eachPrice').val()
-			     				//, 'p_sPrice'		: $('#sPrice').val()
-			     							     				
-						};
-											
-				  	//검색 API를 Ajax로 이용 하기 위한 호출
-					$.ajax({
-		     			url			:	"./jsp_example_send_msg_r1.jsp", 
-		     			//형식을 json으로 받을 것이기 때문에 지정하여 주었습니다.
-		     			dataType	:	"json",		     			 
-		     			async		: false,
-		     			type 		:	"POST",
-		     			
-		     			data : searchWebParam,
-
-						success: function (returnData, status) {
-							console.log('returnData :: ', returnData);
-							
-							if (returnData.resultCode=="0"){
-								//makeResult(returnData);
-								
-								$("span#mgi").text(returnData.data.msgGroupId);
-								$("span#sc").text(returnData.data.successCnt);
-								$("span#fc").text(returnData.data.failCnt);
-								$("span#bc").text(returnData.data.blockCnt);
-								$("span#mt").text(returnData.data.msgType);
-								
-							}	else{								
-								alert(returnData.resultCode+" : "+returnData.data);
-							}							
-							
-						},			     			
-		     			
-		     			error		:	function(request, status, error){
-		     				alert(request+"///"+error+"///"+status+"///"+"AJAX_ERROR");		     				
-		     				console.log("AJAX_ERROR");
-		     			}
-		     		});						
+				//문자발송 REST API를 Ajax로 이용하기 위한 호출
+				$.ajax({
+					url			:	"./jsp_example_send_msg_r1.jsp", //요청 URL
+					dataType	: "json", //요청 값을 json으로 수신
+					async		: false,
+					type 		: "POST", //POST 방식
 					
-			 	 });			     			     	
-		     });
-
-
-			  function makeResult(p_returnData){
-				  
-				  var v_html	=	"";
-
-				  try {
-					  for (var i=0;i<p_returnData.objectList.length;i++){
-						  v_html		+=	"<tr>";				  
-						  v_html		+=	"<td>";
-						  v_html		+=	p_returnData.objectList[i].msgGroupId;
-						  v_html		+=	"</td>";
-						  v_html		+=	"<td>";
-						  v_html		+=	p_returnData.objectList[i].msgTypeName;
-						  v_html		+=	"</td>";
-						  v_html		+=	"<td>";
-						  v_html		+=	p_returnData.objectList[i].callFrom;
-						  v_html		+=	"</td>";
-						  v_html		+=	"<td>";
-						  v_html		+=	p_returnData.objectList[i].ttlCnt;
-						  v_html		+=	"</td>";
-						  v_html		+=	"<td>";
-						  v_html		+=	p_returnData.objectList[i].sCnt;					  
-						  v_html		+=	"</td>";
-						  v_html		+=	"<td>";
-						  v_html		+=	p_returnData.objectList[i].fCnt;
-						  v_html		+=	"</td>";
-						  v_html		+=	"<td>";
-						  v_html		+=	p_returnData.objectList[i].wCnt;
-						  v_html		+=	"</td>";
-						  v_html		+=	"<td>";
-						  v_html		+=	p_returnData.objectList[i].msgResult;
-						  v_html		+=	"</td>";
-						  
-						  v_html		+=	"<td>";
-						  v_html		+=	p_returnData.objectList[i].smsTxt.substring(1,20);
-						  v_html		+=	"</td>";
-						  v_html		+=	"<td>";
-						  v_html		+=	p_returnData.objectList[i].regdate;
-						  v_html		+=	"</td>";
-						  v_html		+=	"<td>";
-						  v_html		+=	p_returnData.objectList[i].reqdate;
-						  v_html		+=	"</td>";
-						  v_html		+=	"<td>";
-						  v_html		+=	p_returnData.objectList[i].remainMsgCnt;
-						  v_html		+=	"</td>";						  
-						  v_html		+=	"</tr>";					  
-						  }
-					  
-					} catch (error) {
-					  console.error(error);
-					  // Expected output: ReferenceError: nonExistentFunction is not defined
-					  // (Note: the exact output may be browser-dependent)
+					data : searchWebParam,
+		
+					success: function (returnData, status) {
+						console.log('returnData :: ', returnData);
+						
+						if (returnData.resultCode=="0"){	//결과가 성공인 경우 결과값 노출
+							
+							$("span#mgi").text(returnData.data.msgGroupId);
+							$("span#sc").text(returnData.data.successCnt);
+							$("span#fc").text(returnData.data.failCnt);
+							$("span#bc").text(returnData.data.blockCnt);
+							$("span#mt").text(returnData.data.msgType);
+							
+						}	else{	//결과가 실패인 경우 원인 노출
+							alert(returnData.resultCode+" : "+returnData.data);
+						}
+						
+					},
+					
+					error		:	function(request, status, error){	//에러가 발생한 경우 에러 노출
+						alert(request+"///"+error+"///"+status+"///"+"AJAX_ERROR");
+						console.log("AJAX_ERROR");
 					}
-
-				  v_html		+=	"";
-
-				  
-				  //$('#divResult').append("aaaaaa");		
-				  $('#dynamicTbody').html(v_html);
-			  }			  
-				  </script>
+				});
+				
+		 	 });
+		});
+	
+	  </script>
 				  
 				  
 <div class="inner">
-	<!-- send top -->
 	<div class="send_top">
 		
 		<div class="mypage_content current" id="tab5_3">
 			<div class="heading">
 				<h2><a href="./jsp_example_start_form_r1.jsp">돌아가기</a></h2>
 				<br/>
+				<!-- 문자발송 설명 및 입력 영역  시작 -->
 				<h2>문자발송(샘플-문자온)</h2>				
 				*mberId와 accessKey값은 실제 서비스시에는 jsp_example_send_msg_r1.jsp 파일에 작성하여 사용하세요
 				<br/>(샘플 페이지에서는 월활한 테스트를 위해 파라미터 형식으로 제공합니다.)
@@ -156,81 +90,73 @@
 						</div>
 					</div>
 
+					<!-- 발신자 번호 -->
 					<div class="input_list_item">
 						<div class="input_left">callFrom
 							<input type="text" class="list_inputType1" id="callFrom" maxlength="100" value="01035520132"  size="100"/>
 						</div>
 					</div>
+					
+					<!-- 수신자 번호 -->
 					<div class="input_list_item">
 						<div class="input_left">callToList
 							<input type="text" class="list_inputType1" id="callToList" maxlength="100" value="01022265487,01063170387,01011112222"  size="100"/>
 						</div>
 					</div>
+					
+					<!-- 문자 내용 -->
 					<div class="input_list_item">
 						<div class="input_left">smsTxt
 							<input type="text" class="list_inputType1" id="smsTxt" maxlength="100" value="문자 테스트~![*이름*]"  size="100"/>
 						</div>
 					</div>
+					
+					<!-- 치환용 이름 -->
 					<div class="input_list_item">
 						<div class="input_left">nameStr
 							<input type="text" class="list_inputType1" id="nameStr" maxlength="100" value="홍길동1|홍길동2|홍길동3"  size="100"/>
 						</div>
 					</div>
+					
+					<!-- 테스트 여부 -->
 					<div class="input_list_item">
 						<div class="input_left">테스트여부
 							<input type="text" class="list_inputType1" id="testYn" maxlength="100" value=""  size="100"/>(기본값 없음, YF-테스트(실패), YS-테스트(성공)
 						</div>
 					</div>
-					<!-- 
-					<div class="input_list_item">
-						<div class="input_left">eachPrice
-							<input type="text" class="list_inputType1" id="eachPrice" maxlength="100" value=""  size="100"/>(기본값 내일)
-						</div>
-					</div>		
-					<div class="input_list_item">
-						<div class="input_left">sPrice
-							<input type="text" class="list_inputType1" id="sPrice" maxlength="100" value=""  size="100"/>(기본값 내일)
-						</div>
-					</div>
-					 -->					
-
-																	
+					<!-- 문자발송 설명 및 입력 영역  끝 -->
 					<div class="mem_btnWrap2">
 						&nbsp;<button type="button" class="mem_btn3" style="width: 100%;" id="ajax_select_price" onclick="return false;">문자발송</button>
-						
 					</div>
 					
 				</div>
 			</div>
 			
+			<!-- 문자 발송 결과값 노출 영역 시작 -->
 			<div class="mem_cont_in">
 				<div class="input_list">					
 					<div class="input_list_item">
 						<div class="input_left">메세지ID : <span class="input_left" id="mgi"></span>
 						</div>
 						
-						<div class="input_left">성공수량 : <span class="input_left" id="sc"></span>							
+						<div class="input_left">성공수량 : <span class="input_left" id="sc"></span>
 						</div>
 
-						<div class="input_left">실패수량 : <span class="input_left" id="fc"></span>							
+						<div class="input_left">실패수량 : <span class="input_left" id="fc"></span>
 						</div>
 
-						<div class="input_left">block수량 : <span class="input_left" id="bc"></span>							
+						<div class="input_left">block수량 : <span class="input_left" id="bc"></span>
 						</div>
 						
-						<div class="input_left">메세지타입 : <span class="input_left" id="mt"></span>							
+						<div class="input_left">메세지타입 : <span class="input_left" id="mt"></span>
 						</div>
-																		
 					</div>
-					
 				</div>
 			</div>
-						
+			<!-- 문자발송 결과값 노출 영역 끝 -->
 			
 		</div>
-		<!--// 마이페이지 - 비밀번호 변경 -->
+
 	</div>
-	<!--// send top -->
 </div>
-<!--// content 영역 -->
 
src/main/webapp/sample_mjon/jsp_example_send_msg_r1.jsp
--- src/main/webapp/sample_mjon/jsp_example_send_msg_r1.jsp
+++ src/main/webapp/sample_mjon/jsp_example_send_msg_r1.jsp
@@ -19,62 +19,45 @@
 <%
 	try{
 		//기본 설정값
-		//final String encodingType = "utf-8";
 		final String encodingType 	=	"UTF-8";
 		final String boundary 		= 	"____boundary____";
 		
-		//회원아이디, APIKEY - 보안을 위해 실제 서비스 시에는 이곳에 mberId와 apiKey 값을 적어서 사용해주세요
+		/******************** 전송 요청 URL  ********************/
+		//final String apiUrl		=	"http://localhost:8088/api/send/sendMsg";
+		final String apiUrl		=	"https://apidev.munjaon.co.kr:9998/api/send/sendMsg";	//개발테스트용 URL
+		//final String apiUrl		=	"https://api.munjaon.co.kr:9998/api/send/sendMsg";	//실제 서비스 URL
+		
+		//회원아이디, APIKEY - 보안을 위해 실제 서비스 시에는 이곳에 mberId와 apiKey 값을 적어서 사용
 		//실제서비스용
-		//final String mberId		=	"goodgkdus";							//문자온 로그인 아이디
+		//final String mberId		=	"goodgkdus";	//문자온 로그인 아이디 
 		//final String apiKey		=	"12e749877379aa7426275414050694b953";	//발급받은 api key
 		
 		//테스트용
 		String mberId		= request.getParameter("p_mberId");			//문자온 로그인 아이디
 		String apiKey		= request.getParameter("p_apiKey");			//발급받은 api key
 	
+		/******************** 전송 정보 ********************/
+		//필수 값
+		String p_callFrom 	= request.getParameter("p_callFrom");	//발신자 번호
+		String p_callToList	= request.getParameter("p_callToList");	//수신자 번호
+		String p_smsTxt		= request.getParameter("p_smsTxt");		//문자 내용
 		
-		/**************** 문자전송하기 예제 ******************/
-		/* "result_code":결과코드,"message":결과문구, */
-		/* "msg_id":메세지ID,"error_cnt":에러갯수,"success_cnt":성공갯수 */
-		/* 동일내용 > 전송용 입니다.  
-		/******************** 인증정보 ********************/
-		//String sms_url = "https://apis.aligo.in/send/"; // 전송요청 URL
-		//String sms_url = "https://api.munjaon.co.kr:9998/api/accessTest/Test"; // 전송요청 URL
-		//String sms_url = "https://api.munjaon.co.kr:9998/api/accessKey/SendMsg"; // 전송요청 URL
-
-		final String apiUrl		=	"http://localhost:8088/api/send/sendMsg";
-// 		final String apiUrl		=	"https://apidev.munjaon.co.kr:9998/api/send/sendMsg";
+		//선택 값
+		String p_nameStr	= request.getParameter("p_nameStr");	//치환용 이름 
+		String p_testYn		= request.getParameter("p_testYn");		//테스트 데이터 여부 '', 'YF', 'YS'
 		
-		Map<String, String> params = new HashMap<String, String>();		
-		/******************** 인증정보 ********************/
+		/* 추후 사용을 위하여 주석 상태로 보존 - 사용자 샘플 JSP에는 해당 내용 삭제 */ 
 		
-
-		//임시	-	테스트용 시작
-		//String p_mberId 	= request.getParameter("p_mberId");	//발신번호
-		//String p_accessKey	= request.getParameter("p_accessKey");	//수신번호
-		//sms.put("mberId", 		p_mberId); // SMS 아이디		
-		//sms.put("accessKey", 	p_accessKey); //인증키
-		//임시	-	테스트용 끝
-		/******************** 전송정보 ********************/
-		//전달 받은 값
-		//필수값
-		String p_callFrom 	= request.getParameter("p_callFrom");	//발신번호
-		String p_callToList	= request.getParameter("p_callToList");	//수신번호
-		String p_eachPrice	= request.getParameter("p_eachPrice");	//전송문자 개별가격
-		//String p_fileCnt	= request.getParameter("p_fileCnt");	//첨부파일갯수
-		String p_sPrice		= request.getParameter("p_sPrice");			//단문문자단가
-		//String p_totPrice	= request.getParameter("p_totPrice");	//총결제금액		
+		//String p_sPrice		= request.getParameter("p_sPrice");		//단문문자단가 
+		//String p_fileCnt	= request.getParameter("p_fileCnt");		//첨부파일갯수 
+		//String p_totPrice	= request.getParameter("p_totPrice");		//총결제금액 		
 		//String p_txtReplYn	= request.getParameter("p_txtReplYn");	//치환문자 여부	Y//N
-		//String p_txtReplYn	= "N";	//치환문자 여부	-	초기 지원안함		
-		//String p_msgType	= request.getParameter("p_msgType");	//문자타입 4-단문,5-URL,6-MMS,7-BARCODE,8-카카오알림톡		
-		//String p_msgKind	= request.getParameter("p_msgKind");	//N-일반,A-광고,C-선거
-		//String p_msgKind	= "N";	//N-일반,A-광고,C-선거	-	초기 지원안함
-		String p_smsTxt		= request.getParameter("p_smsTxt");		//SMS용 메시지본문
-		String p_nameStr	= request.getParameter("p_nameStr");	//치환문자
-		String p_testYn		= request.getParameter("p_testYn");			//테스트데이터여부	'', 'YF', 'YS'
-				
-		//선택값
-		//String p_mmsPrice		= request.getParameter("p_mmsPrice");	//mms단가
+		//String p_txtReplYn	= "N";									//치환문자 여부	- 초기 지원안함
+		//String p_msgType	= request.getParameter("p_msgType"); 		//문자타입 4-단문,5-URL,6-MMS,7-BARCODE,8-카카오알림톡	
+		//String p_msgKind	= request.getParameter("p_msgKind"); 		//N-일반,A-광고,C-선거
+		//String p_msgKind	= "N"; 										//N-일반,A-광고,C-선거	-	초기 지원안함
+
+		//String p_mmsPrice		= request.getParameter("p_mmsPrice"); 	//mms단가
 		//String p_mPrice		= request.getParameter("p_mPrice");		//장문문자단가
 		//String p_spamStatus	= request.getParameter("p_spamStatus");	//스팸문자 유무
 		
@@ -84,19 +67,23 @@
 		//String p_divideTime	= request.getParameter("p_divideTime");		//분할문자 간격
 		//String p_reqDate	= request.getParameter("p_reqDate");		//예약시간
 		
-		// 필수 데이터
-		params.put("mberId", 		mberId); // SMS 아이디		
-		params.put("accessKey", 	apiKey); //인증키		
-		//추가 전송 데이터
-		params.put("callFrom"	, p_callFrom);		//발신번호
-		params.put("callToList"	, p_callToList);	//수신번호
-		//params.put("eachPrice"	, p_eachPrice);		//전송문자 개별가격    
-		//params.put("sPrice"		, p_sPrice);		//단문문자단가
-		params.put("smsTxt"		, p_smsTxt);		//SMS용 메시지본문
-		params.put("nameStr"	, p_nameStr);		//페이지당 출력갯수
-		params.put("test_yn"	, p_testYn);			//테스트 여부
+		/* 추후 사용을 위하여 주석 상태로 보존 - 사용자 샘플 JSP에는 해당 내용 삭제 */ 
+				
+		Map<String, String> params = new HashMap<String, String>();
 		
-            
+		//필수 전송 데이터
+		params.put("mberId", 		mberId); 		//회원 아이디
+		params.put("accessKey", 	apiKey); 		//인증키
+		params.put("callFrom"	, p_callFrom);		//발신자 번호
+		params.put("callToList"	, p_callToList);	//수신자 번호
+		params.put("smsTxt"		, p_smsTxt);		//문자 내용
+		
+		//선택 전송 데이터
+		params.put("nameStr"	, p_nameStr);		//치환용 이름
+		params.put("test_yn"	, p_testYn);		//테스트 데이터 여부
+		
+		
+		//REST API 전송
 		String result = "";
 		
 		MultipartEntityBuilder builder = MultipartEntityBuilder.create();
@@ -111,17 +98,15 @@
 					//전달값이 없는 경우 오류
 					try{
 						builder.addTextBody(key, params.get(key)
-								, ContentType.create("Multipart/related", encodingType));					
+						, ContentType.create("Multipart/related", encodingType));					
 					}catch(Exception ex){
 						ex.printStackTrace();
-						
-					}				
-
-				}					
+					}
+				}
 			}catch(Exception ex){
 				ex.printStackTrace();
 				
-			}				
+			}
 
 		HttpEntity entity = builder.build();
 		
@@ -146,4 +131,8 @@
 		out.print("{\"resultCode\":99,\"message\":\"WRONG API METHOD\"}");
 	}
 	
+
+	/**************** 문자발송 Response  예제 ******************/
+	/* "result_code": 결과코드, "msgGroupId": 메세지 그룹 ID, "msgType": 메세지 타입 */
+	/* "test_yn": 테스트 데이터 여부, "successCnt": 성공 건수 , "blockCnt" : 수신거부 건수*/
 %>
(No newline at end of file)
src/main/webapp/sample_mjon/jsp_example_send_msgs_form_r1.jsp
--- src/main/webapp/sample_mjon/jsp_example_send_msgs_form_r1.jsp
+++ src/main/webapp/sample_mjon/jsp_example_send_msgs_form_r1.jsp
@@ -2,110 +2,100 @@
 <script type="text/javascript" src="./jquery-3.5.0.js"></script>
 
  	<script type="text/javascript">
-			  $(document).ready(function(){
+		$(document).ready(function(){
     
-				//대량문자발송
-				$("#ajax_select_price").click(function(){
+		//대량문자발송
+		$("#ajax_select_price").click(function(){
 
-					$("span#mgi").text("");
-					$("span#sc").text("");
-					$("span#fc").text("");
-					$("span#bc").text("");
-					$("span#mt").text("");
+			$("span#mgi").text("");
+			$("span#sc").text("");
+			$("span#fc").text("");
+			$("span#bc").text("");
+			$("span#mt").text("");
+
+			//문자발송 API로 전송할 데이터
+			var searchWebParam = {
+				'p_mberId'			: $('#mberId').val() 
+				, 'p_apiKey'		: $('#apiKey').val()
+				, 'p_callFrom'		: $('#callFrom').val()
+				, 'p_testYn'		: $('#testYn').val()
+			};
+
+			var tagId = "";
+			//전송할 데이터에 수신자, 문자내용 개수만큼 추가해주기
+			$.each($('.input_list input'), function (index, tag){
+				tagId = $(tag).attr('id');
+				if(tagId.startsWith('p_callTo') || tagId.startsWith('p_smsTxt')){
+					searchWebParam[tagId] = $(tag).val();
+				}
+			});
+		
+			//문자발송 REST API를 Ajax로 이용하기 위한 호출
+			$.ajax({
+				url			:	"./jsp_example_send_msgs_r1.jsp", //요청 URL
+				dataType	:	"json", //요청 값을 json으로 수신
+				async		: false,
+				type 		:	"POST", //POST 방식
+				
+				data : searchWebParam,
+		
+				success: function (returnData, status) {
 					
-					//document.updatePasswordForm.action = '/web/user/sendRESTAPI_test_r1_send.do';
-					//document.updatePasswordForm.submit();
-
-						var searchWebParam = {
-			     				'p_mberId'			: $('#mberId').val() 
-			     				, 'p_apiKey'		: $('#apiKey').val()
-			     				
-			     				, 'p_callFrom'		: $('#callFrom').val()
-			     				, 'p_testYn'		: $('#testYn').val()
-			     							     				
-						};
-
-					var tagId = "";
-					$.each($('.input_list input'), function (index, tag){
+					console.log('returnData : ', returnData);
+					
+					if (returnData.resultCode=="0"){	//결과가 성공인 경우 결과값 노출
+						$("span#mgi").text(returnData.data.msgGroupIdList);
+						$("span#sc").text(returnData.data.successCnt);
+						$("span#fc").text(returnData.data.failCnt);
+						$("span#bc").text(returnData.data.blockCnt);
+						$("span#mt").text(returnData.data.msgTypeList);
 						
-						tagId = $(tag).attr('id');
-						if(tagId.startsWith('p_callTo') || tagId.startsWith('p_smsTxt')){
-
-							searchWebParam[tagId] = $(tag).val();
-						}
-					});
-						
-				  	//검색 API를 Ajax로 이용 하기 위한 호출
-					$.ajax({
-		     			url			:	"./jsp_example_send_msgs_r1.jsp", 
-		     			//형식을 json으로 받을 것이기 때문에 지정하여 주었습니다.
-		     			dataType	:	"json",		     			 
-		     			async		: false,
-		     			type 		:	"POST",
-		     			
-		     			data : searchWebParam,
-
-						success: function (returnData, status) {
-							
-							console.log('returnData : ', returnData);
-							
-							if (returnData.resultCode=="0"){
-								$("span#mgi").text(returnData.data.msgGroupIdList);
-								$("span#sc").text(returnData.data.successCnt);
-								$("span#fc").text(returnData.data.failCnt);
-								$("span#bc").text(returnData.data.blockCnt);
-								$("span#mt").text(returnData.data.msgTypeList);
-								
-							}	else{								
-								alert(returnData.resultCode+" : "+returnData.data);
-							}							
-							
-						},			     			
-		     			
-		     			error		:	function(request, status, error){
-		     				alert(request+"///"+error+"///"+status+"///"+"AJAX_ERROR");		     				
-		     				console.log("AJAX_ERROR");
-		     			}
-		     		});						
+					}	else{	//결과가 실패인 경우 원인 노출
+						alert(returnData.resultCode+" : "+returnData.data);
+					}
 					
-			 	 });	
+				},
+				
+				error		:	function(request, status, error){	//에러가 발생한 경우 에러 노출
+					alert(request+"///"+error+"///"+status+"///"+"AJAX_ERROR");
+					console.log("AJAX_ERROR");
+				}
+			});
 
-			  	// 수신자 추가 버튼
-				$('#sendAdd').click(function(){
+		});	
 
-					
-					var nextId = $('.callTo').length+1;					
-					var textData = '<div class="input_list_item">'
-									+	'<div class="input_left">p_callTo_'+nextId+''
-									+		'<input type="text" class="list_inputType1 callTo" id="p_callTo_'+nextId+'" maxlength="100" value="">'
-									+	'</div>'
-									+'</div>'
-									+'<div class="input_list_item">'
-									+	'<div class="input_left">p_smsTxt_'+nextId+''
-									+		'<input type="text" class="list_inputType1 smsTxt" id="p_smsTxt_'+nextId+'" maxlength="100" value="">'
-									+	'</div>'
-									+'</div>'
+		  	// 수신자 추가 버튼
+			$('#sendAdd').click(function(){
+	
+				
+				var nextId = $('.callTo').length+1;					
+				var textData = '<div class="input_list_item">'
+					+	'<div class="input_left">p_callTo_'+nextId+''
+					+		'<input type="text" class="list_inputType1 callTo" id="p_callTo_'+nextId+'" maxlength="100" value="">'
+					+	'</div>'
+					+'</div>'
+					+'<div class="input_list_item">'
+					+	'<div class="input_left">p_smsTxt_'+nextId+''
+					+		'<input type="text" class="list_inputType1 smsTxt" id="p_smsTxt_'+nextId+'" maxlength="100" value="">'
+					+	'</div>'
+					+'</div>'
 					;
-					
-					$('.input_list').append(textData);
-					
+				$('.input_list').append(textData);
+				
+			});
 
-					
-				});				
-			 	 		     			     	
-		     });
+		});
 
-				  </script>
-				  
+	</script>
 				  
 <div class="inner">
-	<!-- send top -->
 	<div class="send_top">
 		
 		<div class="mypage_content current" id="tab5_3">
 			<div class="heading">
 				<h2><a href="./jsp_example_start_form_r1.jsp">돌아가기</a></h2>
-				<br/>			
+				<br/>	
+				<!-- 문자발송 설명 및 입력 영역  시작 -->
 				<h2>대량문자발송(샘플-문자온)</h2>
 				*mberId와 accessKey값은 실제 서비스시에는 jsp_example_send_msg_r1.jsp 파일에 작성하여 사용하세요
 				<br/>(샘플 페이지에서는 월활한 테스트를 위해 파라미터 형식으로 제공합니다.)
@@ -115,7 +105,6 @@
 			<div class="mem_cont_in">
 			
 					<div class="mem_btnWrap2">
-<!-- 						<button type="button" class="mem_btn3" style="width: 100%;" onclick="insertPw();">변경</button> -->
 						<button type="button" class="mem_btn3" style="width: 50%;" id="sendAdd" onclick="return false;">수신자 추가</button>
 					</div>
 																	
@@ -136,29 +125,37 @@
 						</div>
 					</div>
 
+					<!-- 발신자 번호 -->
 					<div class="input_list_item">
 						<div class="input_left">callFrom
 							<input type="text" class="list_inputType1" id="callFrom" maxlength="100" value="01035520132"  size="100"/>
 						</div>
 					</div>
+					
+					<!-- 테스트 여부 -->
 					<div class="input_list_item">
 						<div class="input_left">테스트여부
 							<input type="text" class="list_inputType1" id="testYn" maxlength="100" value=""  size="100"/>(기본값 없음, YF-테스트(실패), YS-테스트(성공)
 						</div>
 					</div>
+					
+					<!-- 수신자 번호 1-->
 					<div class="input_list_item">
 						<div class="input_left">p_callTo_1
 							<input type="text" class="list_inputType1 callTo" id="p_callTo_1" maxlength="100" value="01083584250">
 						</div>
 					</div>
+					<!-- 문자 내용 1 -->
 					<div class="input_list_item">
 						<div class="input_left">p_smsTxt_1
 							<input type="text" class="list_inputType1 smsTxt" id="p_smsTxt_1" maxlength="100" value="testMsg">
 						</div>
 					</div>
+				<!-- 문자발송 설명 및 입력 영역  끝 -->
 				</div>									
 			</div>	
 			
+			<!-- 문자 발송 결과값 노출 영역 시작 -->
 			<div class="mem_cont_in">				
 					<div class="input_list_item">
 						<div class="input_left">메세지ID : <span class="input_left" id="mgi"></span>
@@ -178,11 +175,7 @@
 																		
 					</div>					
 			</div>					
-						
+			<!-- 문자발송 결과값 노출 영역 끝 -->
 		</div>
-		<!--// 마이페이지 - 비밀번호 변경 -->
 	</div>
-	<!--// send top -->
 </div>
-<!--// content 영역 -->
-
src/main/webapp/sample_mjon/jsp_example_send_msgs_r1.jsp
--- src/main/webapp/sample_mjon/jsp_example_send_msgs_r1.jsp
+++ src/main/webapp/sample_mjon/jsp_example_send_msgs_r1.jsp
@@ -18,94 +18,76 @@
 <%@ page language="java" contentType="text/html; charset=utf-8	" pageEncoding="utf-8"%>
 <%
 	try{
-		//기본 설정값
-		//final String encodingType = "utf-8";
+		//기본 설정값’
 		final String encodingType 	=	"UTF-8";
 		final String boundary 		= 	"____boundary____";
 		
-		//회원아이디, APIKEY - 보안을 위해 실제 서비스 시에는 이곳에 mberId와 apiKey 값을 적어서 사용해주세요
-		//실제서비스용
-		//final String mberId		=	"goodgkdus";							//문자온 로그인 아이디
-		//final String apiKey		=	"12e749877379aa7426275414050694b953";	//발급받은 api key
+		/******************** 전송 요청 URL  ********************/
+		//String apiUrl = "http://localhost:8088/api/send/sendMsgs";
+		//final String apiUrl		=	"https://api.munjaon.co.kr:9998/api/send/sendMsg";	//실제 서비스 URL
+		String apiUrl = "https://apidev.munjaon.co.kr:9998/api/send/sendMsgs"; //개발테스트용 URL
 		
-		//테스트용
-		String mberId		= request.getParameter("p_mberId");			//문자온 로그인 아이디
-		String apiKey		= request.getParameter("p_apiKey");			//발급받은 api key
+		//회원아이디, APIKEY - 보안을 위해 실제 서비스 시에는 이곳에 mberId와 apiKey 값을 적어서 사용
+		//실제서비스용
+		//final String mberId		=	"goodgkdus";	//문자온 로그인 아이디 
+		//final String apiKey		=	"12e749877379aa7426275414050694b953";		//발급받은 api key
+		
+		//테스트용
+		String mberId		= request.getParameter("p_mberId");		//문자온 로그인 아이디
+		String apiKey		= request.getParameter("p_apiKey");		//발급받은 api key
 	
+		/******************** 전송 정보  ********************/
+		//필수 값’
+		String p_callFrom 	= request.getParameter("p_callFrom");	//발신자 번호
+		String p_callTo_1	= request.getParameter("p_callTo_1");	//수신자 번호 1
+		String p_smsTxt_1	= request.getParameter("p_smsTxt_1");	//문자 내용 1
 		
-		/**************** 문자전송하기 예제 ******************/
-		/* "result_code":결과코드,"message":결과문구, */
-		/* "msg_id":메세지ID,"error_cnt":에러갯수,"success_cnt":성공갯수 */
-		/* 동일내용 > 전송용 입니다.  
-		/******************** 인증정보 ********************/
-		//String sms_url = "https://apis.aligo.in/send/"; // 전송요청 URL
-		//String sms_url = "https://api.munjaon.co.kr:9998/api/accessTest/Test"; // 전송요청 URL
-		//String sms_url = "https://api.munjaon.co.kr:9998/api/accessKey/SendMsg"; // 전송요청 URL
-		String apiUrl = "http://localhost:8088/api/send/sendMsgs"; // 전송요청 URL
+		//선택 값
+		String p_testYn		= request.getParameter("p_testYn");		//테스트 데이터 여부	'', 'YF', 'YS'
 
-// 		String apiUrl = "https://apidev.munjaon.co.kr:9998/api/send/sendMsgs"; // 전송요청 URL
+		/* 추후 사용을 위하여 주석 상태로 보존 - 사용자 샘플 JSP에는 해당 내용 삭제 */ 
 		
-		Map<String, String> params = new HashMap<String, String>();		
-		params.put("mberId", 		mberId); // SMS 아이디		
-		params.put("accessKey", 	apiKey); //인증키		
-		/******************** 인증정보 ********************/
+		//String p_nameStr_1	= request.getParameter("p_nameStr_1");	//치환용 이름 1
+		//String p_mmsPrice		= request.getParameter("p_mmsPrice");	//mms 단가
+		//String p_mPrice		= request.getParameter("p_mPrice");		//장문문자단가
+		//String p_spamStatus	= request.getParameter("p_spamStatus");	//스팸문자 유무
 		
-
-		//임시	-	테스트용 시작
-		//String p_mberId 	= request.getParameter("p_mberId");	//발신번호
-		//String p_accessKey	= request.getParameter("p_accessKey");	//수신번호
-		//sms.put("mberId", 		p_mberId); // SMS 아이디		
-		//sms.put("accessKey", 	p_accessKey); //인증키
-		//임시	-	테스트용 끝
-		/******************** 전송정보 ********************/
-		//전달 받은 값
-		//필수값
-		String p_callFrom 	= request.getParameter("p_callFrom");	//발신번호
-		String p_callTo_1	= request.getParameter("p_callTo_1");	//수신번호
-		//String p_eachPrice	= request.getParameter("p_eachPrice");	//전송문자 개별가격
-		//String p_fileCnt	= request.getParameter("p_fileCnt");	//첨부파일갯수
-		//String p_sPrice		= request.getParameter("p_sPrice");			//단문문자단가
-		//String p_totPrice	= request.getParameter("p_totPrice");	//총결제금액		
-		//String p_txtReplYn	= request.getParameter("p_txtReplYn");	//치환문자 여부	Y//N
-		//String p_txtReplYn	= "N";	//치환문자 여부	-	초기 지원안함		
-		//String p_msgType	= request.getParameter("p_msgType");	//문자타입 4-단문,5-URL,6-MMS,7-BARCODE,8-카카오알림톡		
-		//String p_msgKind	= request.getParameter("p_msgKind");	//N-일반,A-광고,C-선거
-		//String p_msgKind	= "N";	//N-일반,A-광고,C-선거	-	초기 지원안함
-		String p_smsTxt_1	= request.getParameter("p_smsTxt_1");		//SMS용 메시지본문
-		String p_testYn		= request.getParameter("p_testYn");			//테스트데이터여부	'', 'YF', 'YS'
-		//String p_nameStr_1	= request.getParameter("p_nameStr_1");	//치환문자
+		//String p_eachPrice	= request.getParameter("p_eachPrice");	//개별 금액
+		//String p_fileCnt	= request.getParameter("p_fileCnt");		//첨부파일갯수
+		//String p_sPrice		= request.getParameter("p_sPrice");		//단문문자단가
+		//String p_totPrice	= request.getParameter("p_totPrice");		//총결제금액		
+		//String p_txtReplYn	= request.getParameter("p_txtReplYn");	//치환문자 여부	Y//N
+		//String p_txtReplYn	= "N";									//치환문자 여부	- 초기 지원안함
+		//String p_msgType	= request.getParameter("p_msgType");		//문자타입 4-단문,5-URL,6-MMS,7-BARCODE,8-카카오알림톡		
+		//String p_msgKind	= request.getParameter("p_msgKind");		//N-일반,A-광고,C-선거
+		//String p_msgKind	= "N";										//N-일반,A-광고,C-선거	-	초기 지원안함
+		
+		//예약문자의 경우(선택값)
+		//String p_reserveYn	= request.getParameter("p_reserveYn");	//예약문자 여부 N or Y
+		//String p_divideCnt	= request.getParameter("p_divideCnt");	//분할문자 건수
+		//String p_divideTime	= request.getParameter("p_divideTime");	//분할문자 간격
+		//String p_reqDate	= request.getParameter("p_reqDate");		//예약시간
 				
-		//선택값
-		//String p_mmsPrice		= request.getParameter("p_mmsPrice");	//mms단가
-		//String p_mPrice		= request.getParameter("p_mPrice");		//장문문자단가
-		//String p_spamStatus	= request.getParameter("p_spamStatus");	//스팸문자 유무
-		
-		//예약문자의 경우(선택값)
-		//String p_reserveYn	= request.getParameter("p_reserveYn");		//예약문자 여부 N or Y
-		//String p_divideCnt	= request.getParameter("p_divideCnt");		//분할문자 건수
-		//String p_divideTime	= request.getParameter("p_divideTime");		//분할문자 간격
-		//String p_reqDate	= request.getParameter("p_reqDate");		//예약시간
-		
-		
-		//추가 전송 데이터
+		Map<String, String> params = new HashMap<String, String>();		
+
+		//필수 전송 데이터
+		params.put("mberId", 		mberId);	//회원 아이디
+		params.put("accessKey", 	apiKey);	//인증키
 		params.put("callFrom"	, p_callFrom);		//발신번호
+		
+		//선택 전송 데이터
 		params.put("test_yn"	, p_testYn);			//테스트 여부
 		
-		//params.put("callTo_1"	, p_callTo_1);	//수신번호
-		//params.put("eachPrice"	, p_eachPrice);		//전송문자 개별가격    
-		//params.put("sPrice"		, p_sPrice);		//단문문자단가
-		//params.put("smsTxt_1"	, p_smsTxt_1);		//SMS용 메시지본문
-		
-		
-		for (int i=1;i<101;i++){
+		//전송할 데이터에 수신자, 문자내용 개수만큼 추가해주기
+		for (int i=1;i<101;i++){ //최대 수신자 100명
 			String p_callTo	=	"p_callTo_"+Integer.toString(i);
 			String p_smsTxt	=	"p_smsTxt_"+Integer.toString(i);
 			
 			String s_callTo	=	"callTo_"+Integer.toString(i);
 			String s_smsTxt	=	"smsTxt_"+Integer.toString(i);
 			
-			p_callTo_1	= request.getParameter(p_callTo);	//SMS용 메시지본문
-			p_smsTxt_1	= request.getParameter(p_smsTxt);	//SMS용 메시지본문			
+			p_callTo_1	= request.getParameter(p_callTo);
+			p_smsTxt_1	= request.getParameter(p_smsTxt);			
 		
 			
 			System.out.println("======i=====");
@@ -113,18 +95,20 @@
 			System.out.println(p_callTo_1);
 			System.out.println(p_smsTxt_1);
 			
+			
 			if (p_callTo_1 != null 
 					&& p_smsTxt_1 != null
 					&& !"".equals(p_callTo_1)
 					&& !"".equals(p_smsTxt_1)
 					){
-				params.put(s_callTo, p_callTo_1);	//수신번호
-				//params.put("eachPrice"	, p_eachPrice);		//전송문자 개별가격    
-				//params.put("sPrice"		, p_sPrice);		//단문문자단가
-				params.put(s_smsTxt, p_smsTxt_1);		//SMS용 메시지본문
+				params.put(s_callTo, p_callTo_1);	//수신자 추가
+				params.put(s_smsTxt, p_smsTxt_1);	//문자내용 추가
+			} else{
+				break;
 			}
 		}
-            
+		
+		//REST API 전송
 		String result = "";
 		
 		MultipartEntityBuilder builder = MultipartEntityBuilder.create();
@@ -136,7 +120,7 @@
 			try{
 				for(Iterator<String> i = params.keySet().iterator(); i.hasNext();){
 					String key = i.next();
-					//전달값이 없는 경우 오류
+					//전달값이 없는 경우 오류˜
 					try{
 						builder.addTextBody(key, params.get(key)
 								, ContentType.create("Multipart/related", encodingType));					
@@ -174,4 +158,7 @@
 		out.print("{\"resultCode\":99,\"message\":\"WRONG API METHOD\"}");
 	}
 	
+	/**************** 문자발송 Response  예제 ******************/
+	/* "result_code": 결과코드, "msgGroupIdList": 메세지 그룹 ID 리스트, "msgTypeList": 메세지 타입 리스트*/
+	/* "test_yn": 테스트 데이터 여부, "successCnt": 성공 건수 , "blockCnt" : 수신거부 건수, "failCnt": 발송실패 건수*/
 %>
(No newline at end of file)
Add a comment
List