호스팅 [디딤365] 신청내용 SMS발송 [php]
페이지 정보
본문
SMS 발송을 위해서는 SmsForm.htm , SmsForm.php , Snoopy.class.php 3개의 파일이 필요합니다.
1. SmsForm.htm 문자전송 데이타입력화면
<form name="SmsForm" action="SmsForm.php" method="post" style="margin:0px; padding:0px">
<table width="630" border="1" cellpadding="0" cellspacing="0" align="center">
<tr>
<td width="30%" align="center">받는사람</td>
<td width="70%"><input type="text" size="20" name="tran_phone" value="" /></td>
</tr>
<tr>
<td align="center">보내는사람</td>
<td><input type="text" size="20" name="tran_callback" /></td>
</tr>
<tr>
<td align="center">예약전송 일시</td>
<td><input type="text" size="20" name="tran_date" /><br>
<font color="red">예약 전송시에만 입력하세요. 생략시에는 즉시 전송(예. 2003-01-01 13:01)</font>
</td>
</tr>
<tr>
<td align="center">메시지</td>
<td><textarea cols="18" rows="5" class="box" name="tran_msg"></textarea></td>
</tr>
<tr>
<td align="center">계정번호</td>
<td><input type="text" size="20" name="guest_no" value="" /></td>
</tr>
<tr>
<td align="center">계정 인증키</td>
<td><input type="text" size="50" name="guest_key" value="" /></td>
</tr>
</table>
<div align="center">
<input type="submit" value=" 메시지 전송 " width="150">
</div>
</form>
2. Snoopy.Class.php 파일 업로드
SMS전송프로세스 파일과 동일한 경로에 위치해야합니다.
Download : http://sourceforge.net/projects/snoopy/
3. SmsForm.php 문자발송 실행파일
<?php
// php.ini 의 register_globals=off 일 경우 (php >= 4.1.0)
//@extract($_GET);
//@extract($_POST);
//@extract($_SERVER);
//----------------------------------------------------------
// SMS 문자전송 시작
//----------------------------------------------------------
include "Snoopy.class.php";
$snoopy = new Snoopy;
$guest_no = "00000"; //계정번호
$guest_key = "0000"; //계정 인증키
$tran_phone = $_POST["tran_phone"]; //받는사람 핸드폰 번호
$tran_callback = $_POST["tran_callback"]; //보내는사람 핸드폰 번호
$tran_date = $_POST["tran_date"]; //예약전송 일시(생략시 즉시전송)
$tran_msg = $_POST["tran_msg"]; //전송 메시지
// euc-kr 일때
$tran_phone = urlencode(iconv('EUC-KR', 'UTF-8', $tran_phone));
$tran_callback = urlencode(iconv('EUC-KR', 'UTF-8', $tran_callback));
$tran_date = urlencode(iconv('EUC-KR', 'UTF-8', $tran_date));
$tran_msg = urlencode(iconv('EUC-KR', 'UTF-8', $tran_msg));
$guest_no = urlencode(iconv('EUC-KR', 'UTF-8', $guest_no));
$guest_key = urlencode(iconv('EUC-KR', 'UTF-8', $guest_key));
// utf-8 일때
$tran_phone = urlencode($tran_phone);
$tran_callback = urlencode($tran_callback);
$tran_date = urlencode($tran_date);
$tran_msg = urlencode($tran_msg);
$guest_no = urlencode($guest_no);
$guest_key = urlencode($guest_key);
$cmd = "SendSms";
$method = "GET";
$url = "http://www.nesolution.com/service/sms.aspx?cmd={$cmd}&method={$method}&";
$url = $url . "guest_no={$guest_no}&guest_key={$guest_key}&tran_phone={$tran_phone}&";
$url = $url . "tran_callback={$tran_callback}&tran_date={$tran_date}&tran_msg={$tran_msg}";
$snoopy->fetchtext($url);
$send_result = $snoopy->results;
//echo $url."<br>";
//echo "send_result = ".$send_result."<br>";
//----------------------------------------------------------
// SMS 문자전송 끝
//----------------------------------------------------------
?>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
.unnamed1 { font-family:"굴림"; font-size:9pt; line-height:12pt}
//-->
</style>
</head>
<body>
<div align="center">
<h2>SMS 예제소스(php)</h2>
<br>
<span class="unnamed1">전송결과 : <b><?php echo($send_result); ?></b></span>
</div>
</body>
</html>
1. SmsForm.htm 문자전송 데이타입력화면
<form name="SmsForm" action="SmsForm.php" method="post" style="margin:0px; padding:0px">
<table width="630" border="1" cellpadding="0" cellspacing="0" align="center">
<tr>
<td width="30%" align="center">받는사람</td>
<td width="70%"><input type="text" size="20" name="tran_phone" value="" /></td>
</tr>
<tr>
<td align="center">보내는사람</td>
<td><input type="text" size="20" name="tran_callback" /></td>
</tr>
<tr>
<td align="center">예약전송 일시</td>
<td><input type="text" size="20" name="tran_date" /><br>
<font color="red">예약 전송시에만 입력하세요. 생략시에는 즉시 전송(예. 2003-01-01 13:01)</font>
</td>
</tr>
<tr>
<td align="center">메시지</td>
<td><textarea cols="18" rows="5" class="box" name="tran_msg"></textarea></td>
</tr>
<tr>
<td align="center">계정번호</td>
<td><input type="text" size="20" name="guest_no" value="" /></td>
</tr>
<tr>
<td align="center">계정 인증키</td>
<td><input type="text" size="50" name="guest_key" value="" /></td>
</tr>
</table>
<div align="center">
<input type="submit" value=" 메시지 전송 " width="150">
</div>
</form>
2. Snoopy.Class.php 파일 업로드
SMS전송프로세스 파일과 동일한 경로에 위치해야합니다.
Download : http://sourceforge.net/projects/snoopy/
3. SmsForm.php 문자발송 실행파일
<?php
// php.ini 의 register_globals=off 일 경우 (php >= 4.1.0)
//@extract($_GET);
//@extract($_POST);
//@extract($_SERVER);
//----------------------------------------------------------
// SMS 문자전송 시작
//----------------------------------------------------------
include "Snoopy.class.php";
$snoopy = new Snoopy;
$guest_no = "00000"; //계정번호
$guest_key = "0000"; //계정 인증키
$tran_phone = $_POST["tran_phone"]; //받는사람 핸드폰 번호
$tran_callback = $_POST["tran_callback"]; //보내는사람 핸드폰 번호
$tran_date = $_POST["tran_date"]; //예약전송 일시(생략시 즉시전송)
$tran_msg = $_POST["tran_msg"]; //전송 메시지
// euc-kr 일때
$tran_phone = urlencode(iconv('EUC-KR', 'UTF-8', $tran_phone));
$tran_callback = urlencode(iconv('EUC-KR', 'UTF-8', $tran_callback));
$tran_date = urlencode(iconv('EUC-KR', 'UTF-8', $tran_date));
$tran_msg = urlencode(iconv('EUC-KR', 'UTF-8', $tran_msg));
$guest_no = urlencode(iconv('EUC-KR', 'UTF-8', $guest_no));
$guest_key = urlencode(iconv('EUC-KR', 'UTF-8', $guest_key));
// utf-8 일때
$tran_phone = urlencode($tran_phone);
$tran_callback = urlencode($tran_callback);
$tran_date = urlencode($tran_date);
$tran_msg = urlencode($tran_msg);
$guest_no = urlencode($guest_no);
$guest_key = urlencode($guest_key);
$cmd = "SendSms";
$method = "GET";
$url = "http://www.nesolution.com/service/sms.aspx?cmd={$cmd}&method={$method}&";
$url = $url . "guest_no={$guest_no}&guest_key={$guest_key}&tran_phone={$tran_phone}&";
$url = $url . "tran_callback={$tran_callback}&tran_date={$tran_date}&tran_msg={$tran_msg}";
$snoopy->fetchtext($url);
$send_result = $snoopy->results;
//echo $url."<br>";
//echo "send_result = ".$send_result."<br>";
//----------------------------------------------------------
// SMS 문자전송 끝
//----------------------------------------------------------
?>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
.unnamed1 { font-family:"굴림"; font-size:9pt; line-height:12pt}
//-->
</style>
</head>
<body>
<div align="center">
<h2>SMS 예제소스(php)</h2>
<br>
<span class="unnamed1">전송결과 : <b><?php echo($send_result); ?></b></span>
</div>
</body>
</html>
댓글목록
등록된 댓글이 없습니다.