카페24 sms 셋팅 ?

카페24 sms 셋팅 ?

QA

카페24 sms 셋팅 ?

답변 3

본문

 

 

홈페이지에서 게시판 작성시 등록된 휴대전화로 sms 통보하f려고 합니다.

고수님들 좀 봐주세요!

 

 

 

(sms 발송 소스) 

 

<?
       
     if($_POST['action']=='go'){

                   /******************** 인증정보 ********************/
                    $sms_url = "http://sslsms.cafe24.com/sms_sender.php"; // 전송요청 URL
                    // $sms_url = "https://sslsms.cafe24.com/sms_sender.php"; // HTTPS 전송요청 URL
                    $sms['user_id'] = base64_encode("hskim0103"); //SMS 아이디.
                    $sms['secure'] = base64_encode("2664f653f80b0fbebbccc14b28d08f43") ;//인증키
                    $sms['msg'] = base64_encode(stripslashes($_POST['msg'])),$wr_name.":".$wr_5;
                    if($_POST['smsType'] == 'L') {
                        $sms['subject'] = base64_encode($_POST['subject']); //제목
                    }

                    $sms['rphone'] = base64_encode($_POST['*** 개인정보보호를 위한 휴대폰번호 노출방지 ***']);
                    $sms['sphone1'] = base64_encode($_POST['sphone1']);
                    $sms['sphone2'] = base64_encode($_POST['sphone2']);
                    $sms['sphone3'] = base64_encode($_POST['sphone3']);
                    $sms['rdate'] = base64_encode($_POST['rdate']);
                    $sms['rtime'] = base64_encode($_POST['rtime']);
                    $sms['mode'] = base64_encode("1"); // base64 사용시 반드시 모드값을 1로 주셔야 합니다.
                    $sms['returnurl'] = base64_encode($_POST['returnurl']);
                    $sms['testflag'] = base64_encode($_POST['testflag']);
                    $sms['destination'] = base64_encode($_POST['destination']);
                    $returnurl = $_POST['returnurl'];
                    $sms['repeatFlag'] = base64_encode($_POST['repeatFlag']);
                    $sms['repeatNum'] = base64_encode($_POST['repeatNum']);
                    $sms['repeatTime'] = base64_encode($_POST['repeatTime']);
                    $sms['smsType'] = base64_encode($_POST['smsType']); // LMS일경우 L

                    $nointeractive = $_POST['nointeractive']; //사용할 경우 : 1, 성공시 대화상자(alert)를 생략

                    $host_info = explode("/", $sms_url);
                    $host = $host_info[2];
                    $path = $host_info[3];

                    srand((double)microtime()*1000000);
                    $boundary = "---------------------".substr(md5(rand(0,32000)),0,10);
                    //print_r($sms);

                    // 헤더 생성
                    $header = "POST /".$path ." HTTP/1.0\r\n";
                    $header .= "Host: ".$host."\r\n";
                    $header .= "Content-type: multipart/form-data, boundary=".$boundary."\r\n";

                    // 본문 생성
                    foreach($sms AS $index => $value){
                        $data .="--$boundary\r\n";
                        $data .= "Content-Disposition: form-data; name=\"".$index."\"\r\n";
                        $data .= "\r\n".$value."\r\n";
                        $data .="--$boundary\r\n";
                    }
                    $header .= "Content-length: " . strlen($data) . "\r\n\r\n";

                    $fp = fsockopen($host, 80);

                    if ($fp) {
                        fputs($fp, $header.$data);
                        $rsp = '';
                        while(!feof($fp)) {
                            $rsp .= fgets($fp,8192);
                        }
                        fclose($fp);
                        $msg = explode("\r\n\r\n",trim($rsp));
                        $rMsg = explode(",", $msg[1]);
                        $Result= $rMsg[0]; //발송결과
                        $Count= $rMsg[1]; //잔여건수

                        //발송결과 알림
                        if($Result=="success") {
                            $alert = "성공";
                            $alert .= " 잔여건수는 ".$Count."건 입니다.";
                        }
                        else if($Result=="reserved") {
                            $alert = "성공적으로 예약되었습니다.";
                            $alert .= " 잔여건수는 ".$Count."건 입니다.";
                        }
                        else if($Result=="3205") {
                            $alert = "잘못된 번호형식입니다.";
                        }

                        else if($Result=="0044") {
                            $alert = "스팸문자는발송되지 않습니다.";
                        }

                        else {
                            $alert = "[Error]".$Result;
                        }
                    }
                    else {
                        $alert = "Connection Failed";
                    }

                    if($nointeractive=="1" && ($Result!="success" && $Result!="Test Success!" && $Result!="reserved") ) {
                        echo "<script>alert('".$alert ."')</script>";
                    }
                    else if($nointeractive!="1") {
                        echo "<script>alert('".$alert ."')</script>";
                    }
                    echo "<script>location.href='".$returnurl."';</script>";
                }
               
        ​ 

이 질문에 댓글 쓰기 :

답변 3

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 21
© SIRSOFT
현재 페이지 제일 처음으로