diff --git a/vendor/_dist/lguplus/cancel.php b/vendor/_dist/lguplus/cancel.php new file mode 100644 index 0000000..ec1ce18 --- /dev/null +++ b/vendor/_dist/lguplus/cancel.php @@ -0,0 +1,31 @@ +getHandle( "/v1/cancel" ); + + $data = array( + "grp_id" => "DjKFPUX6VH7kCAD", + ); + + $msg->setData( $ch, $data ); + + $response = $msg->sendGet($ch); + if ($response === FALSE) { + die(curl_error($ch)); + } + + echo "response = ".$response."\n"; + + } catch(Exception $e) { + echo $e->getMessage(); // get error message + echo $e->getCode(); // get error code + } + +?> diff --git a/vendor/_dist/lguplus/cash.php b/vendor/_dist/lguplus/cash.php new file mode 100644 index 0000000..6b8704c --- /dev/null +++ b/vendor/_dist/lguplus/cash.php @@ -0,0 +1,27 @@ +getHandle( "/v1/cash" ); + + $msg->setData( $ch, null ); + + $response = $msg->sendGet($ch); + if ($response === FALSE) { + die(curl_error($ch)); + } + + echo "response = ".$response."\n"; + + } catch(Exception $e) { + echo $e->getMessage(); // get error message + echo $e->getCode(); // get error code + } + +?> diff --git a/vendor/_dist/lguplus/openapi/message.php b/vendor/_dist/lguplus/openapi/message.php new file mode 100644 index 0000000..d13590d --- /dev/null +++ b/vendor/_dist/lguplus/openapi/message.php @@ -0,0 +1,241 @@ +API_KEY = $api_key; + $this->API_PWD = $pwd; + $this->algorithm = $algorithm; + $this->debug = $debug; + } + + /* + 전문 발송용 cURL 핸들 생성 + */ + function getHandle( $cur_url ) { + $ch = curl_init(); + + // SSL 접속 설정 + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 인증서 체크같은데 true 시 안되는 경우가 많다. + curl_setopt($ch, CURLOPT_SSLVERSION,CURL_SSLVERSION_TLSv1_2); // SSL 버젼 (https 접속시에 필요) + + curl_setopt($ch, CURLOPT_TIMEOUT, 30); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // 결과값 수신여부 + + curl_setopt($ch, CURLOPT_URL, self::URL . $cur_url); + + if($this->debug==true) echo "URL : ".self::URL.$cur_url."\r\n"; + return $ch; + } + + /* + 전문 헤더 생성 + */ + function getHeader() { + $timestamp = time(true)*1000; + $randomStr = rand(1000000000, 9999999999); // 10자리 랜덤숫자 + + $hmac = $this->get_hmac($timestamp, $randomStr); + + $headers = array( + 'charset=utf-8', + 'api_key: '.$this->API_KEY, + 'algorithm: '.$this->algorithm, + 'hash_hmac: '.$hmac, + 'cret_txt: '.$randomStr, + 'timestamp: '.$timestamp, + ); + if($this->debug==true) echo "getHeader()=".print_r($headers, true)."\r\n"; + + return $headers; + } + + /* + HASH_HMAC 생성 + */ + function get_hmac( $timestamp, $randomStr ) { + + $sb = $this->API_KEY; + $sb .= $timestamp; + $sb .= $randomStr; // 10자리 랜덤숫자 + $sb .= $this->API_PWD; // 사용자 API_KEY 비밀번호 + if($this->debug==true) echo "sb = ".$sb."\n"; + + switch ($this->algorithm) { + case "0": + $hmac = hash( "sha256", $sb ); + break; + case "1": + $hmac = sha1( $sb ); + break; + case "2": + $hmac = md5( $sb ); + break; + } + + if($this->debug==true) echo "hmac = ".$hmac."\r\n"; + return $hmac; + } + + function setData( $ch, $data ) { + $headers = $this->getHeader(); + $headers[] = 'Accept: application/json'; + $headers[] = 'Content-Type: application/json'; + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + + curl_setopt($ch, CURLOPT_POSTFIELDS, $this->getData($data)); + } + + /* + multipart/form-data Request body 정보 생성 + */ + function setDataFile($ch, $postfields) { + $algos = hash_algos(); + $hashAlgo = null; + foreach ( array('sha1', 'md5') as $preferred ) { + if ( in_array($preferred, $algos) ) { + $hashAlgo = $preferred; + break; + } + } + if ( $hashAlgo === null ) { list($hashAlgo) = $algos; } + $boundary = + '----------------------------' . + substr(hash($hashAlgo, 'cURL-php-multiple-value-same-key-support' . microtime()), 0, 12); + + $body = array(); + $crlf = "\r\n"; + $fields = array(); + foreach ( $postfields as $key => $value ) { + if ( is_array($value) ) { + foreach ( $value as $v ) { + $fields[] = array($key, $v); + } + } else { + $fields[] = array($key, $value); + } + } + foreach ( $fields as $field ) { + list($key, $value) = $field; + if ( strpos($value, '@') === 0 ) { + preg_match('/^@(.*?)$/', $value, $matches); + list($dummy, $filename) = $matches; + $body[] = '--' . $boundary; + $body[] = 'Content-Disposition: form-data; name="' . $key . '"; filename="' . basename($filename) . '"'; + $body[] = 'Content-Type: image/jpeg'; + $body[] = ''; + $body[] = file_get_contents($filename); + } else { + $body[] = '--' . $boundary; + $body[] = 'Content-Disposition: form-data; name="' . $key . '"'; + $body[] = 'Content-Type: application/json'; + $body[] = ''; + $body[] = $value; + } + } + $body[] = '--' . $boundary . '--'; + $body[] = ''; + + $content = join($crlf, $body); + + curl_setopt($ch, CURLOPT_POSTFIELDS, $content); + + $headers = $this->getHeader(); + $headers[] = 'Content-Type: multipart/form-data'; + + $contentLength = strlen($content); + $headers[] = 'Content-Length: ' . $contentLength; + $headers[] = 'Expect: 100-continue'; + + $contentType = 'boundary=' . $boundary; + // $contentType = 'multipart/form-data; boundary=' . $boundary; + $headers[] = 'Content-Type: ' . $contentType; + + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + } + + /* + POST 방식으로 API를 호출한다. (발송용) + */ + function sendPost( $ch ) { + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); + + $response = curl_exec($ch); + + $response_header = curl_getinfo($ch); + if($this->debug==true) echo "http_code = ".$response_header["http_code"]."\n"; +// if($this->debug==true) echo "response = ".$response."\n"; + + curl_close($ch); + + return $response; + } + + /* + GET 방식으로 API를 호출한다. (조회용) + */ + function sendGet( $ch ) { + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); + + $response = curl_exec($ch); + + $response_header = curl_getinfo($ch); + if($this->debug==true) echo "http_code = ".$response_header["http_code"]."\n"; +// if($this->debug==true) echo "response = ".$response."\n"; + + curl_close($ch); + + return $response; + } + + /* + 첨부파일 정보 생성 + */ + function getFile( $fileName ) { + $file_name_with_full_path = realpath( $fileName ); + $cFile = '@' . realpath($file_name_with_full_path); + return $cFile; + } + + /* + 데이터를 json 형태 string 으로 변환 + */ + function getData( $data ) { + if ($data == "" || $data == null) + $str = "{}"; + else { + $str = json_encode($data); + if ($str == "[]") + $str = "{}"; + } + + if($this->debug==true) echo "getData = ".$str."\r\n"; + return $str; + } +} +?> diff --git a/vendor/_dist/lguplus/pop.php b/vendor/_dist/lguplus/pop.php new file mode 100644 index 0000000..0305a6b --- /dev/null +++ b/vendor/_dist/lguplus/pop.php @@ -0,0 +1,31 @@ +getHandle( "/v1/pop" ); + + $data = array( + "limit" => "100", //요청개수 + ); + + $msg->setData( $ch, $data ); + + $response = $msg->sendGet($ch); + if ($response === FALSE) { + die(curl_error($ch)); + } + + echo "response = ".$response."\n"; + + } catch(Exception $e) { + echo $e->getMessage(); // get error message + echo $e->getCode(); // get error code + } + +?> diff --git a/vendor/_dist/lguplus/readme.txt b/vendor/_dist/lguplus/readme.txt new file mode 100644 index 0000000..6fb2667 --- /dev/null +++ b/vendor/_dist/lguplus/readme.txt @@ -0,0 +1 @@ +PHP 5 >= 5.2.0, PECL json >= 1.2.0, php-curl diff --git a/vendor/_dist/lguplus/send.php b/vendor/_dist/lguplus/send.php new file mode 100644 index 0000000..1dc7330 --- /dev/null +++ b/vendor/_dist/lguplus/send.php @@ -0,0 +1,39 @@ +getHandle( "/v1/send" ); + + $data = array( + "send_type" => "S", // 발송형태(R:예약,S:즉시) + "msg_type" => "S", // SMS : S, LMS : L, MMS : M + "to" => "01011112222", // 수신자번호, ","으로 구분하여 100개까지 지정 가능하다. + "from" => "01000000000", // 발신자 번호, 발신자 번호는 사전등록된 번호여야 한다. + "subject" => "sampleTest", // LMS, MMS 의 경우, 제목을 입력할 수 있다. + "msg" => "본문 내용", // 메시지 본문 내용 + "device_id" => "", // 디바이스 아이디를 지정하여 특정 디바이스를 발송제어할 수 있다. + "datetime" => "", // 예약시간(YYYYMMDDHH24MI) + "country" => "82", // 국가 코드 + ); + + $msg->setData( $ch, $data ); + + $response = $msg->sendPost($ch); + if ($response === FALSE) { + die(curl_error($ch)); + } + + echo "response = ".$response."\n"; + + } catch(Exception $e) { + echo $e->getMessage(); // get error message + echo $e->getCode(); // get error code + } + +?> diff --git a/vendor/_dist/lguplus/sendMMS.php b/vendor/_dist/lguplus/sendMMS.php new file mode 100644 index 0000000..b80669d --- /dev/null +++ b/vendor/_dist/lguplus/sendMMS.php @@ -0,0 +1,44 @@ +getHandle( "/v1/sendMMS" ); + + $params = array( + "send_type" => "S", // 발송형태(R:예약,S:즉시) + "msg_type" => "S", // SMS : S, LMS : L, MMS : M + "to" => "01011112222", // 수신자번호, ","으로 구분하여 100개까지 지정 가능하다. + "from" => "01000000000", // 발신자 번호, 발신자 번호는 사전등록된 번호여야 한다. + "subject" => "sampleTest", // LMS, MMS 의 경우, 제목을 입력할 수 있다. + "msg" => "본문 내용", // 메시지 본문 내용 + "device_id" => "", // 디바이스 아이디를 지정하여 특정 디바이스를 발송제어할 수 있다. + "datetime" => "", // 예약시간(YYYYMMDDHH24MI) + "country" => "82", // 국가 코드 + ); + + $data = array( + "jsonData" => $msg->getData($params), + "image" => array ( $msg->getFile("./test.jpg"), $msg->getFile("./test.jpg"), $msg->getFile("./test.jpg")), + ); + + $msg->setDataFile( $ch, $data ); + + $response = $msg->sendPost($ch); + if ($response === FALSE) { + die(curl_error($ch)); + } + + echo "response = ".$response."\n"; + + } catch(Exception $e) { + echo $e->getMessage(); // get error message + echo $e->getCode(); // get error code + } + +?> diff --git a/vendor/_dist/lguplus/sent.php b/vendor/_dist/lguplus/sent.php new file mode 100644 index 0000000..f749251 --- /dev/null +++ b/vendor/_dist/lguplus/sent.php @@ -0,0 +1,32 @@ +getHandle( "/v1/sent" ); + + $data = array( + "grp_id" => "DjKFPUX6VH7kCAD", + "limit" => "1" + ); + + $msg->setData( $ch, $data ); + + $response = $msg->sendGet($ch); + if ($response === FALSE) { + die(curl_error($ch)); + } + + echo "response = ".$response."\n"; + + } catch(Exception $e) { + echo $e->getMessage(); // get error message + echo $e->getCode(); // get error code + } + +?> diff --git a/vendor/_dist/lguplus/status.php b/vendor/_dist/lguplus/status.php new file mode 100644 index 0000000..29166ef --- /dev/null +++ b/vendor/_dist/lguplus/status.php @@ -0,0 +1,32 @@ +getHandle( "/v1/status" ); + + $data = array( + "type" => "d", // m : 월, d : 일 + "send_date" => date("Ymd"), // 조회일자 + ); + + $msg->setData( $ch, $data ); + + $response = $msg->sendGet($ch); + if ($response === FALSE) { + die(curl_error($ch)); + } + + echo "response = ".$response."\n"; + + } catch(Exception $e) { + echo $e->getMessage(); // get error message + echo $e->getCode(); // get error code + } + +?> diff --git a/vendor/_dist/lguplus/test.jpg b/vendor/_dist/lguplus/test.jpg new file mode 100644 index 0000000..3b947a8 Binary files /dev/null and b/vendor/_dist/lguplus/test.jpg differ