팝빌 알림톡 제거 완료
- 광고성 및 회원관리파일(친구톡 코드만 제거) 제외
This commit is contained in:
@ -1,9 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 LinkHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@ -1,9 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 LinkHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@ -1,4 +0,0 @@
|
||||
linkhub.auth.php
|
||||
================
|
||||
|
||||
링크허브 API 인증 SDK for PHP5
|
||||
@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once 'linkhub.auth.php';
|
||||
|
||||
$ServiceID = 'POPBILL_TEST';
|
||||
$LinkID = 'TESTER';
|
||||
$SecretKey = 'SwWxqU+0TErBXy/9TVjIPEnI0VTUMMSQZtJf3Ed8q3I=';
|
||||
|
||||
//통신방식 기본은 CURL , curl 사용에 문제가 있을경우 STREAM 사용가능.
|
||||
//STREAM 사용시에는 allow_fopen_url = on 으로 설정해야함.
|
||||
define('LINKHUB_COMM_MODE','STREAM');
|
||||
|
||||
$AccessID = '1231212312';
|
||||
$Linkhub = Linkhub::getInstance($LinkID,$SecretKey);
|
||||
|
||||
try
|
||||
{
|
||||
$Token = $Linkhub->getToken($ServiceID,$AccessID, array('member','110'));
|
||||
}catch(LinkhubException $le) {
|
||||
echo $le;
|
||||
|
||||
exit();
|
||||
}
|
||||
echo 'Token is issued : '.substr($Token->session_token,0,20).' ...';
|
||||
echo chr(10);
|
||||
|
||||
try
|
||||
{
|
||||
$balance = $Linkhub->getBalance($Token->session_token,$ServiceID);
|
||||
}catch(LinkhubException $le) {
|
||||
echo $le;
|
||||
|
||||
exit();
|
||||
}
|
||||
echo 'remainPoint is '. $balance;
|
||||
echo chr(10);
|
||||
|
||||
try
|
||||
{
|
||||
$balance = $Linkhub->getPartnerBalance($Token->session_token,$ServiceID);
|
||||
}catch(LinkhubException $le) {
|
||||
echo $le;
|
||||
|
||||
exit();
|
||||
}
|
||||
echo 'remainPartnerPoint is '. $balance;
|
||||
echo chr(10);
|
||||
|
||||
?>
|
||||
@ -1,337 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* =====================================================================================
|
||||
* Class for develop interoperation with Linkhub APIs.
|
||||
* Functionalities are authentication for Linkhub api products, and to support
|
||||
* several base infomation(ex. Remain point).
|
||||
*
|
||||
* This module uses curl and openssl for HTTPS Request. So related modules must
|
||||
* be installed and enabled.
|
||||
*
|
||||
* http://www.linkhub.co.kr
|
||||
* Author : Kim Seongjun
|
||||
* Contributor : Jeong Yohan (code@linkhubcorp.com)
|
||||
* Contributor : Jeong Wooseok (code@linkhubcorp.com)
|
||||
* Written : 2017-08-29
|
||||
* Updated : 2024-10-15
|
||||
*
|
||||
* Thanks for your interest.
|
||||
* We welcome any suggestions, feedbacks, blames or anythings.
|
||||
*
|
||||
* Update Log
|
||||
* - 2017/08/29 GetPartnerURL API added
|
||||
* - 2023/02/10 Request Header User-Agent added
|
||||
* - 2023/08/02 AuthURL Setter added
|
||||
* - 2023/08/11 ServiceURL Rename
|
||||
* - 2024/09/26 Timeout added
|
||||
* ======================================================================================
|
||||
*/
|
||||
class Linkhub
|
||||
{
|
||||
const VERSION = '2.0';
|
||||
const ServiceURL = 'https://auth.linkhub.co.kr';
|
||||
const ServiceURL_Static = 'https://static-auth.linkhub.co.kr';
|
||||
const ServiceURL_GA = 'https://ga-auth.linkhub.co.kr';
|
||||
|
||||
private $__LinkID;
|
||||
private $__SecretKey;
|
||||
private $__requestMode = LINKHUB_COMM_MODE;
|
||||
private $__ServiceURL;
|
||||
|
||||
public function getSecretKey(){
|
||||
return $this->__SecretKey;
|
||||
}
|
||||
public function getLinkID(){
|
||||
return $this->__LinkID;
|
||||
}
|
||||
public function ServiceURL($V){
|
||||
$this->__ServiceURL = $V;
|
||||
}
|
||||
private static $singleton = null;
|
||||
public static function getInstance($LinkID,$secretKey)
|
||||
{
|
||||
if(is_null(Linkhub::$singleton)) {
|
||||
Linkhub::$singleton = new Linkhub();
|
||||
}
|
||||
Linkhub::$singleton->__LinkID = $LinkID;
|
||||
Linkhub::$singleton->__SecretKey = $secretKey;
|
||||
|
||||
return Linkhub::$singleton;
|
||||
}
|
||||
public function gzdecode($data){
|
||||
return gzinflate(substr($data, 10, -8));
|
||||
}
|
||||
|
||||
private function executeCURL($url,$header = array(),$isPost = false, $postdata = null) {
|
||||
$base_header = array();
|
||||
$base_header[] = 'Accept-Encoding: gzip,deflate';
|
||||
$base_header[] = 'User-Agent: PHP5 LINKHUB SDK';
|
||||
$arr_header = $header + $base_header;
|
||||
|
||||
if($this->__requestMode != "STREAM") {
|
||||
$http = curl_init($url);
|
||||
|
||||
if($isPost) {
|
||||
curl_setopt($http, CURLOPT_POST,1);
|
||||
curl_setopt($http, CURLOPT_POSTFIELDS, $postdata);
|
||||
}
|
||||
curl_setopt($http, CURLOPT_HTTPHEADER,$arr_header);
|
||||
curl_setopt($http, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
curl_setopt($http, CURLOPT_ENCODING, 'gzip,deflate');
|
||||
// Connection timeout 설정
|
||||
curl_setopt($http, CURLOPT_CONNECTTIMEOUT_MS, 10 * 1000);
|
||||
// 통합 timeout 설정
|
||||
curl_setopt($http, CURLOPT_TIMEOUT_MS, 180 * 1000);
|
||||
|
||||
$responseJson = curl_exec($http);
|
||||
|
||||
// curl Error 추가
|
||||
if ($responseJson == false) {
|
||||
throw new LinkhubException(curl_error($http));
|
||||
}
|
||||
|
||||
$http_status = curl_getinfo($http, CURLINFO_HTTP_CODE);
|
||||
|
||||
curl_close($http);
|
||||
|
||||
$is_gzip = 0 === mb_strpos($responseJson, "\x1f" . "\x8b" . "\x08");
|
||||
|
||||
if ($is_gzip) {
|
||||
$responseJson = $this->gzdecode($responseJson);
|
||||
}
|
||||
|
||||
if($http_status != 200) {
|
||||
throw new LinkhubException($responseJson);
|
||||
}
|
||||
|
||||
return json_decode($responseJson);
|
||||
|
||||
}
|
||||
else {
|
||||
if($isPost) {
|
||||
$params = array('http' => array(
|
||||
'ignore_errors' => TRUE,
|
||||
'method' => 'POST',
|
||||
'protocol_version' => '1.0',
|
||||
'content' => $postdata,
|
||||
'timeout' => 180
|
||||
));
|
||||
} else {
|
||||
$params = array('http' => array(
|
||||
'ignore_errors' => TRUE,
|
||||
'method' => 'GET',
|
||||
'protocol_version' => '1.0',
|
||||
'timeout' => 180
|
||||
));
|
||||
}
|
||||
if ($arr_header !== null) {
|
||||
$head = "";
|
||||
foreach($arr_header as $h) {
|
||||
$head = $head . $h . "\r\n";
|
||||
}
|
||||
$params['http']['header'] = substr($head,0,-2);
|
||||
}
|
||||
$ctx = stream_context_create($params);
|
||||
$response = file_get_contents($url, false, $ctx);
|
||||
|
||||
$is_gzip = 0 === mb_strpos($response , "\x1f" . "\x8b" . "\x08");
|
||||
if($is_gzip){
|
||||
$response = $this->gzdecode($response);
|
||||
}
|
||||
|
||||
if ($http_response_header[0] != "HTTP/1.1 200 OK") {
|
||||
throw new LinkhubException($response);
|
||||
}
|
||||
|
||||
return json_decode($response);
|
||||
}
|
||||
}
|
||||
|
||||
public function getTime($useStaticIP = false, $useLocalTimeYN = true, $useGAIP = false) {
|
||||
if($useLocalTimeYN) {
|
||||
$replace_search = array("@","#");
|
||||
$replace_target = array("T","Z");
|
||||
|
||||
$date = new DateTime('now', new DateTimeZone('UTC'));
|
||||
|
||||
return str_replace($replace_search, $replace_target, $date->format('Y-m-d@H:i:s#'));
|
||||
}
|
||||
if($this->__requestMode != "STREAM") {
|
||||
$targetURL = $this->getTargetURL($useStaticIP, $useGAIP);
|
||||
|
||||
$http = curl_init($targetURL.'/Time');
|
||||
|
||||
curl_setopt($http, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
// Read timeout 설정
|
||||
curl_setopt($http, CURLOPT_TIMEOUT_MS, 180 * 1000);
|
||||
// Connection timeout 설정
|
||||
curl_setopt($http, CURLOPT_CONNECTTIMEOUT_MS, 10 * 1000);
|
||||
|
||||
$response = curl_exec($http);
|
||||
|
||||
// curl Error 추가
|
||||
if ($response == false) {
|
||||
throw new LinkhubException(curl_error($http));
|
||||
}
|
||||
|
||||
$http_status = curl_getinfo($http, CURLINFO_HTTP_CODE);
|
||||
|
||||
curl_close($http);
|
||||
|
||||
if($http_status != 200) {
|
||||
throw new LinkhubException($response);
|
||||
}
|
||||
return $response;
|
||||
|
||||
} else {
|
||||
$header = array();
|
||||
$header[] = 'Connection: close';
|
||||
$params = array('http' => array(
|
||||
'ignore_errors' => TRUE,
|
||||
'protocol_version' => '1.0',
|
||||
'method' => 'GET',
|
||||
'timeout' => 180
|
||||
));
|
||||
if ($header !== null) {
|
||||
$head = "";
|
||||
foreach($header as $h) {
|
||||
$head = $head . $h . "\r\n";
|
||||
}
|
||||
$params['http']['header'] = substr($head,0,-2);
|
||||
}
|
||||
|
||||
$ctx = stream_context_create($params);
|
||||
|
||||
$targetURL = $this->getTargetURL($useStaticIP, $useGAIP);
|
||||
|
||||
$response = (file_get_contents( $targetURL.'/Time', false, $ctx));
|
||||
|
||||
if ($http_response_header[0] != "HTTP/1.1 200 OK") {
|
||||
throw new LinkhubException($response);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
public function getToken($ServiceID, $access_id, array $scope = array() , $forwardIP = null, $useStaticIP = false, $useLocalTimeYN = true, $useGAIP = false)
|
||||
{
|
||||
$xDate = $this->getTime($useStaticIP, $useLocalTimeYN, $useGAIP);
|
||||
|
||||
$uri = '/' . $ServiceID . '/Token';
|
||||
$header = array();
|
||||
|
||||
$TokenRequest = new TokenRequest();
|
||||
$TokenRequest->access_id = $access_id;
|
||||
$TokenRequest->scope = $scope;
|
||||
|
||||
$postdata = json_encode($TokenRequest);
|
||||
|
||||
$digestTarget = 'POST'.chr(10);
|
||||
$digestTarget = $digestTarget.base64_encode(hash('sha256',$postdata,true)).chr(10);
|
||||
$digestTarget = $digestTarget.$xDate.chr(10);
|
||||
if(!(is_null($forwardIP) || $forwardIP == '')) {
|
||||
$digestTarget = $digestTarget.$forwardIP.chr(10);
|
||||
}
|
||||
$digestTarget = $digestTarget.Linkhub::VERSION.chr(10);
|
||||
$digestTarget = $digestTarget.$uri;
|
||||
|
||||
$digest = base64_encode(hash_hmac('sha256',$digestTarget,base64_decode(strtr($this->__SecretKey, '-_', '+/')),true));
|
||||
|
||||
$header[] = 'x-lh-date: '.$xDate;
|
||||
$header[] = 'x-lh-version: '.Linkhub::VERSION;
|
||||
if(!(is_null($forwardIP) || $forwardIP == '')) {
|
||||
$header[] = 'x-lh-forwarded: '.$forwardIP;
|
||||
}
|
||||
|
||||
$header[] = 'Authorization: LINKHUB '.$this->__LinkID.' '.$digest;
|
||||
$header[] = 'Content-Type: Application/json';
|
||||
$header[] = 'Connection: close';
|
||||
|
||||
$targetURL = $this->getTargetURL($useStaticIP, $useGAIP);
|
||||
|
||||
return $this->executeCURL($targetURL.$uri , $header,true,$postdata);
|
||||
}
|
||||
|
||||
|
||||
public function getBalance($bearerToken, $ServiceID, $useStaticIP = false, $useGAIP = false)
|
||||
{
|
||||
$header = array();
|
||||
$header[] = 'Authorization: Bearer '.$bearerToken;
|
||||
$header[] = 'Connection: close';
|
||||
|
||||
$targetURL = $this->getTargetURL($useStaticIP, $useGAIP);
|
||||
$uri = '/'.$ServiceID.'/Point';
|
||||
|
||||
$response = $this->executeCURL($targetURL.$uri,$header);
|
||||
return $response->remainPoint;
|
||||
|
||||
}
|
||||
|
||||
public function getPartnerBalance($bearerToken, $ServiceID, $useStaticIP = false, $useGAIP = false)
|
||||
{
|
||||
$header = array();
|
||||
$header[] = 'Authorization: Bearer '.$bearerToken;
|
||||
$header[] = 'Connection: close';
|
||||
|
||||
$targetURL = $this->getTargetURL($useStaticIP, $useGAIP);
|
||||
$uri = '/'.$ServiceID.'/PartnerPoint';
|
||||
|
||||
$response = $this->executeCURL($targetURL.$uri,$header);
|
||||
return $response->remainPoint;
|
||||
}
|
||||
|
||||
/*
|
||||
* 파트너 포인트 충전 팝업 URL 추가 (2017/08/29)
|
||||
*/
|
||||
public function getPartnerURL($bearerToken, $ServiceID, $TOGO, $useStaticIP = false, $useGAIP = false)
|
||||
{
|
||||
$header = array();
|
||||
$header[] = 'Authorization: Bearer '.$bearerToken;
|
||||
$header[] = 'Connection: close';
|
||||
|
||||
$targetURL = $this->getTargetURL($useStaticIP, $useGAIP);
|
||||
$uri = '/'.$ServiceID.'/URL?TG='.$TOGO;
|
||||
|
||||
$response = $this->executeCURL($targetURL.$uri, $header);
|
||||
return $response->url;
|
||||
}
|
||||
|
||||
private function getTargetURL($useStaticIP, $useGAIP){
|
||||
if(isset($this->__ServiceURL)) {
|
||||
return $this->__ServiceURL;
|
||||
}
|
||||
|
||||
if($useGAIP){
|
||||
return Linkhub::ServiceURL_GA;
|
||||
} else if($useStaticIP){
|
||||
return Linkhub::ServiceURL_Static;
|
||||
} else {
|
||||
return Linkhub::ServiceURL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TokenRequest
|
||||
{
|
||||
public $access_id;
|
||||
public $scope;
|
||||
}
|
||||
|
||||
class LinkhubException extends Exception
|
||||
{
|
||||
public function __construct($response, Exception $previous = null) {
|
||||
$Err = json_decode($response);
|
||||
if(is_null($Err)) {
|
||||
parent::__construct($response, -99999999);
|
||||
}
|
||||
else {
|
||||
parent::__construct($Err->message, $Err->code);
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,679 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* =====================================================================================
|
||||
* Class for base module for Popbill API SDK. It include base functionality for
|
||||
* RESTful web service request and parse json result. It uses Linkhub module
|
||||
* to accomplish authentication APIs.
|
||||
*
|
||||
* This module uses curl and openssl for HTTPS Request. So related modules must
|
||||
* be installed and enabled.
|
||||
*
|
||||
* http://www.linkhub.co.kr
|
||||
* Author : Jeong YoHan (code@linkhubcorp.com)
|
||||
* Written : 2018-03-02
|
||||
* Updated : 2025-01-13
|
||||
*
|
||||
* Thanks for your interest.
|
||||
* We welcome any suggestions, feedbacks, blames or anything.
|
||||
* ======================================================================================
|
||||
*/
|
||||
require_once 'popbill.php';
|
||||
|
||||
class KakaoService extends PopbillBase {
|
||||
|
||||
public function __construct($LinkID, $SecretKey)
|
||||
{
|
||||
parent::__construct($LinkID, $SecretKey);
|
||||
$this->AddScope('153');
|
||||
$this->AddScope('154');
|
||||
$this->AddScope('155');
|
||||
}
|
||||
|
||||
// 전송 단가 확인
|
||||
public function GetUnitCost($CorpNum, $MessageType) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($MessageType)) {
|
||||
throw new PopbillException('카카오톡 전송유형이 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
return $this->executeCURL('/KakaoTalk/UnitCost?Type=' . $MessageType, $CorpNum)->unitCost;
|
||||
}
|
||||
|
||||
// 알림톡/친구톡 전송내역 확인
|
||||
public function GetMessages($CorpNum, $ReceiptNum, $UserID = null) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($ReceiptNum)) {
|
||||
throw new PopbillException('카카오톡 접수번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$response = $this->executeCURL('/KakaoTalk/' . $ReceiptNum, $CorpNum, $UserID);
|
||||
$DetailInfo = new KakaoSentInfo();
|
||||
$DetailInfo->fromJsonInfo($response);
|
||||
|
||||
return $DetailInfo;
|
||||
}
|
||||
|
||||
// 알림톡/친구톡 전송내역 확인 (요청번호 할당)
|
||||
public function GetMessagesRN($CorpNum, $RequestNum, $UserID = null) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($RequestNum)) {
|
||||
throw new PopbillException('카카오톡 전송요청번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$response = $this->executeCURL('/KakaoTalk/Get/' . $RequestNum, $CorpNum, $UserID);
|
||||
$DetailInfo = new KakaoSentInfo();
|
||||
$DetailInfo->fromJsonInfo($response);
|
||||
|
||||
return $DetailInfo;
|
||||
}
|
||||
|
||||
// 카카오톡 채널 목록 확인
|
||||
public function ListPlusFriendID($CorpNum) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$PlusFriendList = array();
|
||||
$response = $this->executeCURL('/KakaoTalk/ListPlusFriendID', $CorpNum);
|
||||
|
||||
for ($i = 0; $i < Count($response); $i++) {
|
||||
$PlusFriendObj = new PlusFriend();
|
||||
$PlusFriendObj->fromJsonInfo($response[$i]);
|
||||
$PlusFriendList[$i] = $PlusFriendObj;
|
||||
}
|
||||
|
||||
return $PlusFriendList;
|
||||
}
|
||||
|
||||
// 알림톡 템플릿 목록 확인
|
||||
public function ListATSTemplate($CorpNum) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$result = $this->executeCURL('/KakaoTalk/ListATSTemplate', $CorpNum);
|
||||
|
||||
$TemplateList = array();
|
||||
for ($i = 0; $i < Count($result); $i++) {
|
||||
$TemplateObj = new ATSTemplate();
|
||||
$TemplateObj->fromJsonInfo($result[$i]);
|
||||
$TemplateList[$i] = $TemplateObj;
|
||||
}
|
||||
|
||||
return $TemplateList;
|
||||
}
|
||||
|
||||
// 발신번호 등록여부 확인
|
||||
public function CheckSenderNumber($CorpNum, $SenderNumber, $UserID = null) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($SenderNumber)) {
|
||||
throw new PopbillException('발신번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
return $this->executeCURL('/KakaoTalk/CheckSenderNumber/' . $SenderNumber, $CorpNum, $UserID);
|
||||
}
|
||||
|
||||
// 발신번호 목록 확인
|
||||
public function GetSenderNumberList($CorpNum) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
return $this->executeCURL('/Message/SenderNumber', $CorpNum);
|
||||
}
|
||||
|
||||
// 예약전송 취소 (접수번호)
|
||||
public function CancelReserve($CorpNum, $ReceiptNum, $UserID = null) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($ReceiptNum)) {
|
||||
throw new PopbillException('예약전송을 취소할 접수번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
return $this->executeCURL('/KakaoTalk/' . $ReceiptNum . '/Cancel', $CorpNum, $UserID);
|
||||
}
|
||||
|
||||
// 예약전송 전체 취소 (전송 요청번호)
|
||||
public function CancelReserveRN($CorpNum, $RequestNum, $UserID = null) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($RequestNum)) {
|
||||
throw new PopbillException('예약전송을 취소할 전송요청번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
return $this->executeCURL('/KakaoTalk/Cancel/' . $RequestNum, $CorpNum, $UserID);
|
||||
}
|
||||
|
||||
// 예약전송 일부 취소 (접수번호)
|
||||
public function CancelReservebyRCV($CorpNum, $ReceiptNum, $ReceiveNum, $UserID = null) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($ReceiptNum)) {
|
||||
throw new PopbillException('예약전송 취소할 접수번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($ReceiveNum)) {
|
||||
throw new PopbillException('예약전송 취소할 수신번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$postdata = json_encode($ReceiveNum);
|
||||
|
||||
return $this->executeCURL('/KakaoTalk/' . $ReceiptNum . '/Cancel', $CorpNum, $UserID, true, null, $postdata);
|
||||
}
|
||||
|
||||
// 예약전송 일부 취소 (전송 요청번호)
|
||||
public function CancelReserveRNbyRCV($CorpNum, $RequestNum, $ReceiveNum, $UserID = null) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($RequestNum)) {
|
||||
throw new PopbillException('예약전송 취소할 전송요청번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($ReceiveNum)) {
|
||||
throw new PopbillException('예약전송 취소할 수신번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$postdata = json_encode($ReceiveNum);
|
||||
|
||||
return $this->executeCURL('/KakaoTalk/Cancel/' . $RequestNum, $CorpNum, $UserID, true, null, $postdata);
|
||||
}
|
||||
|
||||
public function GetURL($CorpNum, $UserID, $TOGO)
|
||||
{
|
||||
$URI = '/KakaoTalk/?TG=';
|
||||
|
||||
if ($TOGO == "SENDER") {
|
||||
$URI = '/Message/?TG=';
|
||||
}
|
||||
|
||||
$response = $this->executeCURL($URI . $TOGO, $CorpNum, $UserID);
|
||||
return $response->url;
|
||||
}
|
||||
|
||||
// 플러스친구 계정관리 팝업 URL
|
||||
public function GetPlusFriendMgtURL($CorpNum, $UserID = null) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$response = $this->executeCURL('/KakaoTalk/?TG=PLUSFRIEND', $CorpNum, $UserID);
|
||||
return $response->url;
|
||||
}
|
||||
|
||||
// 발신번호 관리 팝업 URL
|
||||
public function GetSenderNumberMgtURL($CorpNum, $UserID = null) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$response = $this->executeCURL('/Message/?TG=SENDER', $CorpNum, $UserID);
|
||||
return $response->url;
|
||||
}
|
||||
|
||||
// 알림톡 템플릿관리 팝업 URL
|
||||
public function GetATSTemplateMgtURL($CorpNum, $UserID = null) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$response = $this->executeCURL('/KakaoTalk/?TG=TEMPLATE', $CorpNum, $UserID);
|
||||
return $response->url;
|
||||
}
|
||||
|
||||
// 알림톡 템플릿 정보 확인
|
||||
public function GetATSTemplate($CorpNum, $TemplateCode, $UserID = null) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($TemplateCode)) {
|
||||
throw new PopbillException('템플릿코드가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$result = $this->executeCURL('/KakaoTalk/GetATSTemplate/'.$TemplateCode, $CorpNum, $UserID);
|
||||
|
||||
$TemplateInfo = new ATSTemplate();
|
||||
$TemplateInfo->fromJsonInfo($result);
|
||||
|
||||
return $TemplateInfo;
|
||||
}
|
||||
|
||||
// 카카오톡 전송내역 팝업 URL
|
||||
public function GetSentListURL($CorpNum, $UserID = null) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$response = $this->executeCURL('/KakaoTalk/?TG=BOX', $CorpNum, $UserID);
|
||||
return $response->url;
|
||||
}
|
||||
|
||||
// 전송내역 목록 조회
|
||||
public function Search($CorpNum, $SDate, $EDate, $State = array(), $Item = array(), $ReserveYN = null, $SenderYN = false, $Page = null, $PerPage = null, $Order = null, $UserID = null, $QString = null) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($SDate)) {
|
||||
throw new PopbillException('시작일자가 입력되지 않았습니다.');
|
||||
}
|
||||
if(!$this->isValidDate($SDate)) {
|
||||
throw new PopbillException('시작일자가 유효하지 않습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($EDate)) {
|
||||
throw new PopbillException('종료일자가 입력되지 않았습니다.');
|
||||
}
|
||||
if(!$this->isValidDate($EDate)) {
|
||||
throw new PopbillException('종료일자가 유효하지 않습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($State)) {
|
||||
throw new PopbillException('전송상태가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$uri = '/KakaoTalk/Search';
|
||||
$uri .= '?SDate=' . $SDate;
|
||||
$uri .= '&EDate=' . $EDate;
|
||||
$uri .= '&State=' . implode(',', $State);
|
||||
|
||||
if(!$this->isNullOrEmpty($Item)) {
|
||||
$uri .= '&Item=' . implode(',', $Item);
|
||||
}
|
||||
if(!is_null($ReserveYN) && $ReserveYN != "") {
|
||||
if($ReserveYN) {
|
||||
$uri .= '&ReserveYN=1';
|
||||
}else{
|
||||
$uri .= '&ReserveYN=0';
|
||||
}
|
||||
}
|
||||
if ($SenderYN) {
|
||||
$uri .= '&SenderOnly=1';
|
||||
} else {
|
||||
$uri .= '&SenderOnly=0';
|
||||
}
|
||||
if(!$this->isNullOrEmpty($Page)) {
|
||||
$uri .= '&Page=' . $Page;
|
||||
}
|
||||
if(!$this->isNullOrEmpty($PerPage)) {
|
||||
$uri .= '&PerPage=' . $PerPage;
|
||||
}
|
||||
if(!$this->isNullOrEmpty($Order)) {
|
||||
$uri .= '&Order=' . $Order;
|
||||
}
|
||||
if(!$this->isNullOrEmpty($QString)) {
|
||||
$uri .= '&QString=' . urlencode($QString);
|
||||
}
|
||||
|
||||
$response = $this->executeCURL($uri, $CorpNum, $UserID);
|
||||
|
||||
$SearchList = new KakaoSearchResult();
|
||||
$SearchList->fromJsonInfo($response);
|
||||
|
||||
return $SearchList;
|
||||
|
||||
}
|
||||
|
||||
// 과금정보 확인
|
||||
public function GetChargeInfo($CorpNum, $MessageType, $UserID = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($MessageType)) {
|
||||
throw new PopbillException('카카오톡 전송유형이 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$uri = '/KakaoTalk/ChargeInfo?Type=' . $MessageType;
|
||||
|
||||
$response = $this->executeCURL($uri, $CorpNum, $UserID);
|
||||
$ChargeInfo = new ChargeInfo();
|
||||
$ChargeInfo->fromJsonInfo($response);
|
||||
|
||||
return $ChargeInfo;
|
||||
}
|
||||
|
||||
// 친구톡(이미지)
|
||||
public function SendFMS($CorpNum, $PlusFriendID, $Sender = null, $Content = null, $AltContent = null, $AltSendType = null, $AdsYN = false, $Messages = array(), $Btns = array(), $ReserveDT = null, $FilePaths = array(), $ImageURL = null, $UserID = null, $RequestNum = null, $AltSubject = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($PlusFriendID)) {
|
||||
throw new PopbillException('카카오톡 채널 검색용 아이디가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($Messages)) {
|
||||
throw new PopbillException('카카오톡 전송정보가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($FilePaths)) {
|
||||
throw new PopbillException('전송할 이미지 파일 경로가 입력되지 않았습니다.');
|
||||
}
|
||||
if(!$this->isNullOrEmpty($ReserveDT) && !$this->isValidDT($ReserveDT)) {
|
||||
throw new PopbillException('전송 예약일시가 유효하지 않습니다.');
|
||||
}
|
||||
|
||||
$Request = array();
|
||||
|
||||
if(!$this->isNullOrEmpty($PlusFriendID)) $Request['plusFriendID'] = $PlusFriendID;
|
||||
if(!$this->isNullOrEmpty($Sender)) $Request['snd'] = $Sender;
|
||||
if(!$this->isNullOrEmpty($Content)) $Request['content'] = $Content;
|
||||
if(!$this->isNullOrEmpty($AltSubject)) $Request['altSubject'] = $AltSubject;
|
||||
if(!$this->isNullOrEmpty($AltContent)) $Request['altContent'] = $AltContent;
|
||||
if(!$this->isNullOrEmpty($AltSendType)) $Request['altSendType'] = $AltSendType;
|
||||
if(!$this->isNullOrEmpty($ReserveDT)) $Request['sndDT'] = $ReserveDT;
|
||||
if(!$this->isNullOrEmpty($AdsYN)) $Request['adsYN'] = $AdsYN;
|
||||
if(!$this->isNullOrEmpty($ImageURL)) $Request['imageURL'] = $ImageURL;
|
||||
if(!$this->isNullOrEmpty($RequestNum)) $Request['requestNum'] = $RequestNum;
|
||||
if(!$this->isNullOrEmpty($Btns)) $Request['btns'] = $Btns;
|
||||
|
||||
$Request['msgs'] = $Messages;
|
||||
$postdata = array();
|
||||
$postdata['form'] = json_encode($Request);
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach ($FilePaths as $FilePath) {
|
||||
$postdata['file'] = '@' . $FilePath;
|
||||
}
|
||||
|
||||
return $this->executeCURL('/FMS', $CorpNum, $UserID, true, null, $postdata, true)->receiptNum;
|
||||
}
|
||||
|
||||
// 친구톡(텍스트)
|
||||
public function SendFTS($CorpNum, $PlusFriendID, $Sender = null, $Content = null, $AltContent = null, $AltSendType = null, $AdsYN = false, $Messages = array(), $Btns = array(), $ReserveDT = null, $UserID = null, $RequestNum = null, $AltSubject = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($PlusFriendID)) {
|
||||
throw new PopbillException('카카오톡 채널 검색용 아이디가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($Messages)) {
|
||||
throw new PopbillException('카카오톡 전송정보가 입력되지 않았습니다.');
|
||||
}
|
||||
if(!$this->isNullOrEmpty($ReserveDT) && !$this->isValidDT($ReserveDT)) {
|
||||
throw new PopbillException('전송 예약일시가 유효하지 않습니다.');
|
||||
}
|
||||
|
||||
$Request = array();
|
||||
|
||||
if(!$this->isNullOrEmpty($PlusFriendID)) $Request['plusFriendID'] = $PlusFriendID;
|
||||
if(!$this->isNullOrEmpty($Sender)) $Request['snd'] = $Sender;
|
||||
if(!$this->isNullOrEmpty($Content)) $Request['content'] = $Content;
|
||||
if(!$this->isNullOrEmpty($AltSubject)) $Request['altSubject'] = $AltSubject;
|
||||
if(!$this->isNullOrEmpty($AltContent)) $Request['altContent'] = $AltContent;
|
||||
if(!$this->isNullOrEmpty($AltSendType)) $Request['altSendType'] = $AltSendType;
|
||||
if(!$this->isNullOrEmpty($ReserveDT)) $Request['sndDT'] = $ReserveDT;
|
||||
if(!$this->isNullOrEmpty($AdsYN)) $Request['adsYN'] = $AdsYN;
|
||||
if(!$this->isNullOrEmpty($RequestNum)) $Request['requestNum'] = $RequestNum;
|
||||
if(!$this->isNullOrEmpty($Btns)) $Request['btns'] = $Btns;
|
||||
|
||||
$Request['msgs'] = $Messages;
|
||||
$postdata = json_encode($Request);
|
||||
|
||||
return $this->executeCURL('/FTS', $CorpNum, $UserID, true, null, $postdata)->receiptNum;
|
||||
}
|
||||
|
||||
// 알림톡 단건전송
|
||||
public function SendATS($CorpNum, $TemplateCode, $Sender = null, $Content = null, $AltContent = null, $AltSendType = null, $Messages = array(), $ReserveDT = null, $UserID = null, $RequestNum = null, $Btns = null, $AltSubject = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($TemplateCode)) {
|
||||
throw new PopbillException('승인된 알림톡 템플릿코드가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($Messages)) {
|
||||
throw new PopbillException('카카오톡 전송정보가 입력되지 않았습니다.');
|
||||
}
|
||||
if(!$this->isNullOrEmpty($ReserveDT) && !$this->isValidDT($ReserveDT)) {
|
||||
throw new PopbillException('전송 예약일시가 유효하지 않습니다.');
|
||||
}
|
||||
|
||||
$Request = array();
|
||||
|
||||
if(!$this->isNullOrEmpty($TemplateCode)) $Request['templateCode'] = $TemplateCode;
|
||||
if(!$this->isNullOrEmpty($Sender)) $Request['snd'] = $Sender;
|
||||
if(!$this->isNullOrEmpty($Content)) $Request['content'] = $Content;
|
||||
if(!$this->isNullOrEmpty($AltSubject)) $Request['altSubject'] = $AltSubject;
|
||||
if(!$this->isNullOrEmpty($AltContent)) $Request['altContent'] = $AltContent;
|
||||
if(!$this->isNullOrEmpty($AltSendType)) $Request['altSendType'] = $AltSendType;
|
||||
if(!$this->isNullOrEmpty($ReserveDT)) $Request['sndDT'] = $ReserveDT;
|
||||
if(!$this->isNullOrEmpty($RequestNum)) $Request['requestNum'] = $RequestNum;
|
||||
if(!$this->isNullOrEmpty($Btns)) $Request['btns'] = $Btns;
|
||||
|
||||
$Request['msgs'] = $Messages;
|
||||
|
||||
$postdata = json_encode($Request);
|
||||
|
||||
return $this->executeCURL('/ATS', $CorpNum, $UserID, true, null, $postdata)->receiptNum;
|
||||
}
|
||||
}
|
||||
|
||||
class ENumKakaoType
|
||||
{
|
||||
const ATS = 'ATS';
|
||||
const FTS = 'FTS';
|
||||
const FMS = 'FMS';
|
||||
}
|
||||
|
||||
class KakaoSearchResult
|
||||
{
|
||||
public $code;
|
||||
public $message;
|
||||
public $total;
|
||||
public $perPage;
|
||||
public $pageNum;
|
||||
public $pageCount;
|
||||
|
||||
public $list;
|
||||
|
||||
function fromJsonInfo($jsonInfo)
|
||||
{
|
||||
|
||||
isset($jsonInfo->code) ? ($this->code = $jsonInfo->code) : null;
|
||||
isset($jsonInfo->message) ? ($this->message = $jsonInfo->message) : null;
|
||||
isset($jsonInfo->total) ? ($this->total = $jsonInfo->total) : null;
|
||||
isset($jsonInfo->perPage) ? ($this->perPage = $jsonInfo->perPage) : null;
|
||||
isset($jsonInfo->pageNum) ? ($this->pageNum = $jsonInfo->pageNum) : null;
|
||||
isset($jsonInfo->pageCount) ? ($this->pageCount = $jsonInfo->pageCount) : null;
|
||||
|
||||
$DetailList = array();
|
||||
for ($i = 0; $i < Count($jsonInfo->list); $i++) {
|
||||
$SentInfo = new KakaoSentInfoDetail();
|
||||
$SentInfo->fromJsonInfo($jsonInfo->list[$i]);
|
||||
$DetailList[$i] = $SentInfo;
|
||||
}
|
||||
$this->list = $DetailList;
|
||||
}
|
||||
}
|
||||
|
||||
class KakaoSentInfo
|
||||
{
|
||||
public $contentType;
|
||||
public $templateCode;
|
||||
public $plusFriendID;
|
||||
public $sendNum;
|
||||
public $altSubject;
|
||||
public $altContent;
|
||||
public $altSendType;
|
||||
public $reserveDT;
|
||||
public $adsYN;
|
||||
public $imageURL;
|
||||
public $sendCnt;
|
||||
public $successCnt;
|
||||
public $failCnt;
|
||||
public $altCnt;
|
||||
public $cancelCnt;
|
||||
|
||||
public $msgs;
|
||||
public $btns;
|
||||
|
||||
function fromJsonInfo($jsonInfo)
|
||||
{
|
||||
|
||||
isset($jsonInfo->contentType) ? ($this->contentType = $jsonInfo->contentType) : null;
|
||||
isset($jsonInfo->templateCode) ? ($this->templateCode = $jsonInfo->templateCode) : null;
|
||||
isset($jsonInfo->plusFriendID) ? ($this->plusFriendID = $jsonInfo->plusFriendID) : null;
|
||||
isset($jsonInfo->sendNum) ? ($this->sendNum = $jsonInfo->sendNum) : null;
|
||||
isset($jsonInfo->altSubject) ? ($this->altSubject = $jsonInfo->altSubject) : null;
|
||||
isset($jsonInfo->altContent) ? ($this->altContent = $jsonInfo->altContent) : null;
|
||||
isset($jsonInfo->altSendType) ? ($this->altSendType = $jsonInfo->altSendType) : null;
|
||||
isset($jsonInfo->reserveDT) ? ($this->reserveDT = $jsonInfo->reserveDT) : null;
|
||||
isset($jsonInfo->adsYN) ? ($this->adsYN = $jsonInfo->adsYN) : null;
|
||||
isset($jsonInfo->imageURL) ? ($this->imageURL = $jsonInfo->imageURL) : null;
|
||||
isset($jsonInfo->sendCnt) ? ($this->sendCnt = $jsonInfo->sendCnt) : null;
|
||||
isset($jsonInfo->successCnt) ? ($this->successCnt = $jsonInfo->successCnt) : null;
|
||||
isset($jsonInfo->failCnt) ? ($this->failCnt = $jsonInfo->failCnt) : null;
|
||||
isset($jsonInfo->altCnt) ? ($this->altCnt = $jsonInfo->altCnt) : null;
|
||||
isset($jsonInfo->cancelCnt) ? ($this->cancelCnt = $jsonInfo->cancelCnt) : null;
|
||||
|
||||
if (isset($jsonInfo->msgs)) {
|
||||
$msgsList = array();
|
||||
for ($i = 0; $i < Count($jsonInfo->msgs); $i++) {
|
||||
$kakaoDetail = new KakaoSentInfoDetail();
|
||||
$kakaoDetail->fromJsonInfo($jsonInfo->msgs[$i]);
|
||||
$msgsList[$i] = $kakaoDetail;
|
||||
}
|
||||
$this->msgs = $msgsList;
|
||||
} // end of if
|
||||
|
||||
if (isset($jsonInfo->btns)) {
|
||||
$btnsList = array();
|
||||
for ($i = 0; $i < Count($jsonInfo->btns); $i++) {
|
||||
$buttonDetail = new KakaoButton();
|
||||
$buttonDetail->fromJsonInfo($jsonInfo->btns[$i]);
|
||||
$btnsList[$i] = $buttonDetail;
|
||||
}
|
||||
$this->btns = $btnsList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // end of KakaoSentInfo class
|
||||
|
||||
class KakaoSentInfoDetail
|
||||
{
|
||||
public $state;
|
||||
public $sendDT;
|
||||
public $receiveNum;
|
||||
public $receiveName;
|
||||
public $content;
|
||||
public $result;
|
||||
public $resultDT;
|
||||
public $altSubject;
|
||||
public $altContent;
|
||||
public $contentType;
|
||||
public $altContentType;
|
||||
public $altSendDT;
|
||||
public $altResult;
|
||||
public $altResultDT;
|
||||
public $reserveDT;
|
||||
public $receiptNum;
|
||||
public $requestNum;
|
||||
public $interOPRefKey;
|
||||
|
||||
public function fromJsonInfo($jsonInfo)
|
||||
{
|
||||
isset($jsonInfo->state) ? ($this->state = $jsonInfo->state) : null;
|
||||
isset($jsonInfo->sendDT) ? ($this->sendDT = $jsonInfo->sendDT) : null;
|
||||
isset($jsonInfo->receiveNum) ? ($this->receiveNum = $jsonInfo->receiveNum) : null;
|
||||
isset($jsonInfo->receiveName) ? ($this->receiveName = $jsonInfo->receiveName) : null;
|
||||
isset($jsonInfo->content) ? ($this->content = $jsonInfo->content) : null;
|
||||
isset($jsonInfo->result) ? ($this->result = $jsonInfo->result) : null;
|
||||
isset($jsonInfo->resultDT) ? ($this->resultDT = $jsonInfo->resultDT) : null;
|
||||
isset($jsonInfo->altSubject) ? ($this->altSubject = $jsonInfo->altSubject) : null;
|
||||
isset($jsonInfo->altContent) ? ($this->altContent = $jsonInfo->altContent) : null;
|
||||
isset($jsonInfo->contentType) ? ($this->contentType = $jsonInfo->contentType) : null;
|
||||
isset($jsonInfo->altContentType) ? ($this->altContentType = $jsonInfo->altContentType) : null;
|
||||
isset($jsonInfo->altSendDT) ? ($this->altSendDT = $jsonInfo->altSendDT) : null;
|
||||
isset($jsonInfo->altResult) ? ($this->altResult = $jsonInfo->altResult) : null;
|
||||
isset($jsonInfo->altResultDT) ? ($this->altResultDT = $jsonInfo->altResultDT) : null;
|
||||
isset($jsonInfo->reserveDT) ? ($this->reserveDT = $jsonInfo->reserveDT) : null;
|
||||
isset($jsonInfo->receiptNum) ? ($this->receiptNum = $jsonInfo->receiptNum) : null;
|
||||
isset($jsonInfo->requestNum) ? ($this->requestNum = $jsonInfo->requestNum) : null;
|
||||
isset($jsonInfo->interOPRefKey) ? ($this->interOPRefKey = $jsonInfo->interOPRefKey) : null;
|
||||
}
|
||||
}
|
||||
|
||||
class ATSTemplate
|
||||
{
|
||||
public $templateCode;
|
||||
public $templateName;
|
||||
public $template;
|
||||
public $plusFriendID;
|
||||
public $ads;
|
||||
public $appendix;
|
||||
public $btns;
|
||||
public $secureYN;
|
||||
public $state;
|
||||
public $stateDT;
|
||||
|
||||
public function fromJsonInfo($jsonInfo)
|
||||
{
|
||||
isset($jsonInfo->templateCode) ? $this->templateCode = $jsonInfo->templateCode : null;
|
||||
isset($jsonInfo->templateName) ? $this->templateName = $jsonInfo->templateName : null;
|
||||
isset($jsonInfo->template) ? $this->template = $jsonInfo->template : null;
|
||||
isset($jsonInfo->plusFriendID) ? $this->plusFriendID = $jsonInfo->plusFriendID : null;
|
||||
isset($jsonInfo->ads) ? $this->ads = $jsonInfo->ads : null;
|
||||
isset($jsonInfo->appendix) ? $this->appendix = $jsonInfo->appendix : null;
|
||||
isset($jsonInfo->secureYN) ? $this->secureYN = $jsonInfo->secureYN : null;
|
||||
isset($jsonInfo->state) ? $this->state = $jsonInfo->state : null;
|
||||
isset($jsonInfo->stateDT) ? $this->stateDT = $jsonInfo->stateDT : null;
|
||||
|
||||
if(isset($jsonInfo->btns)){
|
||||
$InfoList = array();
|
||||
for ($i = 0; $i < Count($jsonInfo->btns); $i++) {
|
||||
$InfoObj = new KakaoButton();
|
||||
$InfoObj->fromJsonInfo($jsonInfo->btns[$i]);
|
||||
$InfoList[$i] = $InfoObj;
|
||||
}
|
||||
$this->btns = $InfoList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class KakaoButton
|
||||
{
|
||||
public $n;
|
||||
public $t;
|
||||
public $u1;
|
||||
public $u2;
|
||||
public $tg;
|
||||
|
||||
function fromJsonInfo($jsonInfo)
|
||||
{
|
||||
isset($jsonInfo->n) ? $this->n = $jsonInfo->n : null;
|
||||
isset($jsonInfo->t) ? $this->t = $jsonInfo->t : null;
|
||||
isset($jsonInfo->u1) ? $this->u1 = $jsonInfo->u1 : null;
|
||||
isset($jsonInfo->u2) ? $this->u2 = $jsonInfo->u2 : null;
|
||||
isset($jsonInfo->tg) ? $this->tg = $jsonInfo->tg : null;
|
||||
}
|
||||
}
|
||||
|
||||
class PlusFriend
|
||||
{
|
||||
public $plusFriendID;
|
||||
public $plusFriendName;
|
||||
public $regDT;
|
||||
public $state;
|
||||
public $stateDT;
|
||||
|
||||
function fromJsonInfo($jsonInfo)
|
||||
{
|
||||
isset($jsonInfo->plusFriendID) ? $this->plusFriendID = $jsonInfo->plusFriendID : null;
|
||||
isset($jsonInfo->plusFriendName) ? $this->plusFriendName = $jsonInfo->plusFriendName : null;
|
||||
isset($jsonInfo->regDT) ? $this->regDT = $jsonInfo->regDT : null;
|
||||
isset($jsonInfo->state) ? $this->state = $jsonInfo->state : null;
|
||||
isset($jsonInfo->stateDT) ? $this->stateDT = $jsonInfo->stateDT : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@ -1,619 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* =====================================================================================
|
||||
* Class for base module for Popbill API SDK. It include base functionality for
|
||||
* RESTful web service request and parse json result. It uses Linkhub module
|
||||
* to accomplish authentication APIs.
|
||||
*
|
||||
* This module uses curl and openssl for HTTPS Request. So related modules must
|
||||
* be installed and enabled.
|
||||
*
|
||||
* http://www.linkhub.co.kr
|
||||
* Author : Kim Seongjun
|
||||
* Written : 2014-04-15
|
||||
* Contributor : Jeong YoHan (code@linkhubcorp.com)
|
||||
* Updated : 2025-01-13
|
||||
*
|
||||
* Thanks for your interest.
|
||||
* We welcome any suggestions, feedbacks, blames or anything.
|
||||
* ======================================================================================
|
||||
*/
|
||||
require_once 'popbill.php';
|
||||
|
||||
class MessagingService extends PopbillBase {
|
||||
|
||||
public function __construct($LinkID, $SecretKey)
|
||||
{
|
||||
parent::__construct($LinkID, $SecretKey);
|
||||
$this->AddScope('150');
|
||||
$this->AddScope('151');
|
||||
$this->AddScope('152');
|
||||
}
|
||||
|
||||
// 전송단가 확인
|
||||
public function GetUnitCost($CorpNum, $MessageType) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($MessageType)) {
|
||||
throw new PopbillException('문자 전송유형이 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
return $this->executeCURL('/Message/UnitCost?Type=' . $MessageType, $CorpNum)->unitCost;
|
||||
}
|
||||
|
||||
// 발신번호 등록여부 확인
|
||||
public function CheckSenderNumber($CorpNum, $SenderNumber, $UserID = null) {
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($SenderNumber)) {
|
||||
throw new PopbillException('발신번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
return $this->executeCURL('/Message/CheckSenderNumber/' . $SenderNumber, $CorpNum, $UserID);
|
||||
}
|
||||
|
||||
/* 단문메시지 전송
|
||||
* $CorpNum => 발송사업자번호
|
||||
* $Sender => 동보전송용 발신번호 미기재시 개별메시지 발신번호로 전송. 발신번호가 없는 개별메시지에만 동보처리함.
|
||||
* $Content => 동보전송용 발신내용 미기재시 개별메시지 내용으로 전송, 발신내용이 없는 개별메시지에만 동보처리함.
|
||||
* $Messages => 발신메시지 최대 1000건, 배열
|
||||
* 'snd' => 개별발신번호
|
||||
* 'sndnm'=> 발신자명
|
||||
* 'rcv' => 수신번호, 필수
|
||||
* 'rcvnm'=> 수신자 성명
|
||||
* 'msg' => 메시지 내용, 미기재시 동보메시지로 전송함.
|
||||
* 'sjt' => 메시지 제목(SMS 사용 불가, 미입력시 팝빌에서 설정한 기본값 사용)
|
||||
* 'interOPRefKey'=> 파트너 지정 키(SMS/LMS/MMS 대량/동보전송시 파트너가 개별건마다 입력할 수 있는 값)
|
||||
* $ReserveDT => 예약전송시 예약시간 yyyyMMddHHmmss 형식으로 기재
|
||||
* $adsYN => 광고메시지 전송여부, true:광고/false:일반 중 택 1
|
||||
* $UserID => 발신자 팝빌 회원아이디
|
||||
* $SenderName=> 동보전송용 발신자명 미기재시 개별메시지 발신자명으로 전송
|
||||
* $requestNum=> 전송 요청번호
|
||||
*/
|
||||
public function SendSMS($CorpNum, $Sender = null, $Content = null, $Messages = array(), $ReserveDT = null, $adsYN = false, $UserID = null, $SenderName = null, $RequestNum = null)
|
||||
{
|
||||
return $this->SendMessage(ENumMessageType::SMS, $CorpNum, $Sender, $SenderName, null, $Content, $Messages, $ReserveDT, $adsYN, $UserID, $RequestNum);
|
||||
}
|
||||
|
||||
/* 장문메시지 전송
|
||||
* $CorpNum => 발송사업자번호
|
||||
* $Sender => 동보전송용 발신번호 미기재시 개별메시지 발신번호로 전송. 발신번호가 없는 개별메시지에만 동보처리함.
|
||||
* $Subject => 동보전송용 제목 미기재시 개별메시지 제목으로 전송, 제목이 없는 개별메시지에만 동보처리함.
|
||||
* $Content => 동보전송용 발신내용 미기재시 개별베시지 내용으로 전송, 발신내용이 없는 개별메시지에만 동보처리함.
|
||||
* $Messages => 발신메시지 최대 1000건, 배열
|
||||
* 'snd' => 개별발신번호
|
||||
* 'sndnm'=> 발신자명
|
||||
* 'rcv' => 수신번호, 필수
|
||||
* 'rcvnm'=> 수신자 성명
|
||||
* 'msg' => 메시지 내용, 미기재시 동보메시지로 전송함.
|
||||
* 'sjt' => 메시지 제목(SMS 사용 불가, 미입력시 팝빌에서 설정한 기본값 사용)
|
||||
* 'interOPRefKey'=> 파트너 지정 키(SMS/LMS/MMS 대량/동보전송시 파트너가 개별건마다 입력할 수 있는 값)
|
||||
* $ReserveDT => 예약전송시 예약시간 yyyyMMddHHmmss 형식으로 기재
|
||||
* $adsYN => 광고메시지 전송여부, true:광고/false:일반 중 택 1
|
||||
* $UserID => 발신자 팝빌 회원아이디
|
||||
* $SenderName=> 동보전송용 발신자명 미기재시 개별메시지 발신자명으로 전송
|
||||
* $requestNum=> 전송 요청번호
|
||||
*/
|
||||
public function SendLMS($CorpNum, $Sender = null, $Subject = null, $Content = null, $Messages = array(), $ReserveDT = null, $adsYN = false, $UserID = null, $SenderName = null, $RequestNum = null)
|
||||
{
|
||||
return $this->SendMessage(ENumMessageType::LMS, $CorpNum, $Sender, $SenderName, $Subject, $Content, $Messages, $ReserveDT, $adsYN, $UserID, $RequestNum);
|
||||
}
|
||||
|
||||
/* 장/단문메시지 전송 - 메지시 길이에 따라 단문과 장문을 선택하여 전송합니다.
|
||||
* $CorpNum => 발송사업자번호
|
||||
* $Sender => 동보전송용 발신번호 미기재시 개별메시지 발신번호로 전송. 발신번호가 없는 개별메시지에만 동보처리함.
|
||||
* $Subject => 동보전송용 제목 미기재시 개별메시지 제목으로 전송, 제목이 없는 개별메시지에만 동보처리함.
|
||||
* $Content => 동보전송용 발신내용 미기재시 개별베시지 내용으로 전송, 발신내용이 없는 개별메시지에만 동보처리함.
|
||||
* $Messages => 발신메시지 최대 1000건, 배열
|
||||
* 'snd' => 개별발신번호
|
||||
* 'sndnm'=> 발신자명
|
||||
* 'rcv' => 수신번호, 필수
|
||||
* 'rcvnm'=> 수신자 성명
|
||||
* 'msg' => 메시지 내용, 미기재시 동보메시지로 전송함.
|
||||
* 'sjt' => 메시지 제목(SMS 사용 불가, 미입력시 팝빌에서 설정한 기본값 사용)
|
||||
* 'interOPRefKey'=> 파트너 지정 키(SMS/LMS/MMS 대량/동보전송시 파트너가 개별건마다 입력할 수 있는 값)
|
||||
* $ReserveDT => 예약전송시 예약시간 yyyyMMddHHmmss 형식으로 기재
|
||||
* $adsYN => 광고메시지 전송여부, true:광고/false:일반 중 택 1
|
||||
* $UserID => 발신자 팝빌 회원아이디
|
||||
* $SenderName=> 동보전송용 발신자명 미기재시 개별메시지 발신자명으로 전송
|
||||
* $requestNum=> 전송 요청번호
|
||||
*/
|
||||
public function SendXMS($CorpNum, $Sender = null, $Subject = null, $Content = null, $Messages = array(), $ReserveDT = null, $adsYN = false, $UserID = null, $SenderName = null, $RequestNum = null)
|
||||
{
|
||||
return $this->SendMessage(ENumMessageType::XMS, $CorpNum, $Sender, $SenderName, $Subject, $Content, $Messages, $ReserveDT, $adsYN, $UserID, $RequestNum);
|
||||
}
|
||||
|
||||
/* MMS 메시지 전송
|
||||
* $CorpNum => 발송사업자번호
|
||||
* $Sender => 동보전송용 발신번호 미기재시 개별메시지 발신번호로 전송. 발신번호가 없는 개별메시지에만 동보처리함.
|
||||
* $Subject => 동보전송용 제목 미기재시 개별메시지 제목으로 전송, 제목이 없는 개별메시지에만 동보처리함.
|
||||
* $Content => 동보전송용 발신내용 미기재시 개별베시지 내용으로 전송, 발신내용이 없는 개별메시지에만 동보처리함.
|
||||
* $Messages => 발신메시지 최대 1000건, 배열
|
||||
* 'snd' => 개별발신번호
|
||||
* 'sndnm'=> 발신자명
|
||||
* 'rcv' => 수신번호, 필수
|
||||
* 'rcvnm'=> 수신자 성명
|
||||
* 'msg' => 메시지 내용, 미기재시 동보메시지로 전송함.
|
||||
* 'sjt' => 메시지 제목(SMS 사용 불가, 미입력시 팝빌에서 설정한 기본값 사용)
|
||||
* 'interOPRefKey'=> 파트너 지정 키(SMS/LMS/MMS 대량/동보전송시 파트너가 개별건마다 입력할 수 있는 값)
|
||||
* $FilePaths => 전송할 파일경로 문자열
|
||||
* $ReserveDT => 예약전송시 예약시간 yyyyMMddHHmmss 형식으로 기재
|
||||
* $adsYN => 광고메시지 전송여부, true:광고/false:일반 중 택 1
|
||||
* $UserID => 발신자 팝빌 회원아이디
|
||||
* $SenderName => 동보전송용 발신자명 미기재시 개별메시지 발신자명으로 전송
|
||||
* $requestNum => 전송 요청번호
|
||||
*/
|
||||
public function SendMMS($CorpNum, $Sender = null, $Subject = null, $Content = null, $Messages = array(), $FilePaths = array(), $ReserveDT = null, $adsYN = false, $UserID = null, $SenderName = null, $RequestNum = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($Messages)) {
|
||||
throw new PopbillException('전송할 메시지가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($FilePaths)) {
|
||||
throw new PopbillException('전송할 이미지 파일 경로가 입력되지 않았습니다.');
|
||||
}
|
||||
if(!$this->isNullOrEmpty($ReserveDT) && !$this->isValidDT($ReserveDT)) {
|
||||
throw new PopbillException('전송 예약일시가 유효하지 않습니다.');
|
||||
}
|
||||
|
||||
$Request = array();
|
||||
|
||||
if(!$this->isNullOrEmpty($Sender)) $Request['snd'] = $Sender;
|
||||
if(!$this->isNullOrEmpty($Subject)) $Request['subject'] = $Subject;
|
||||
if(!$this->isNullOrEmpty($Content)) $Request['content'] = $Content;
|
||||
if(!$this->isNullOrEmpty($ReserveDT)) $Request['sndDT'] = $ReserveDT;
|
||||
if(!$this->isNullOrEmpty($SenderName)) $Request['sndnm'] = $SenderName;
|
||||
if(!$this->isNullOrEmpty($RequestNum)) $Request['requestNum'] = $RequestNum;
|
||||
|
||||
if ($adsYN) $Request['adsYN'] = $adsYN;
|
||||
|
||||
$Request['msgs'] = $Messages;
|
||||
|
||||
$postdata = array();
|
||||
$postdata['form'] = json_encode($Request);
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach ($FilePaths as $FilePath) {
|
||||
$postdata['file'] = '@' . $FilePath;
|
||||
}
|
||||
|
||||
return $this->executeCURL('/MMS', $CorpNum, $UserID, true, null, $postdata, true)->receiptNum;
|
||||
}
|
||||
|
||||
/* 전송메시지 내역 및 전송상태 확인
|
||||
* $CorpNum => 발송사업자번호
|
||||
* $ReceiptNum=> 접수번호
|
||||
* $UserID => 팝빌 회원아이디
|
||||
*/
|
||||
public function GetMessages($CorpNum, $ReceiptNum, $UserID = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($ReceiptNum)) {
|
||||
throw new PopbillException('접수번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$result = $this->executeCURL('/Message/' . $ReceiptNum, $CorpNum, $UserID);
|
||||
|
||||
$MessageInfoList = array();
|
||||
|
||||
for ($i = 0; $i < Count($result); $i++) {
|
||||
$MsgInfo = new MessageInfo();
|
||||
$MsgInfo->fromJsonInfo($result[$i]);
|
||||
$MessageInfoList[$i] = $MsgInfo;
|
||||
}
|
||||
return $MessageInfoList;
|
||||
}
|
||||
|
||||
/* 전송메시지 내역 및 전송상태 확인
|
||||
* $CorpNum => 발송사업자번호
|
||||
* $RequestNum=> 전송요청번호
|
||||
* $UserID => 팝빌 회원아이디
|
||||
*/
|
||||
public function GetMessagesRN($CorpNum, $RequestNum, $UserID = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($RequestNum)) {
|
||||
throw new PopbillException('전송요청번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$result = $this->executeCURL('/Message/Get/' . $RequestNum, $CorpNum, $UserID);
|
||||
|
||||
$MessageInfoList = array();
|
||||
|
||||
for ($i = 0; $i < Count($result); $i++) {
|
||||
$MsgInfo = new MessageInfo();
|
||||
$MsgInfo->fromJsonInfo($result[$i]);
|
||||
$MessageInfoList[$i] = $MsgInfo;
|
||||
}
|
||||
return $MessageInfoList;
|
||||
}
|
||||
|
||||
/* 예약전송 취소
|
||||
* $CorpNum => 발송사업자번호
|
||||
* $ReceiptNum=> 접수번호
|
||||
* $UserID => 팝빌 회원아이디
|
||||
*/
|
||||
public function CancelReserve($CorpNum, $ReceiptNum, $UserID = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($ReceiptNum)) {
|
||||
throw new PopbillException('예약전송 취소할 접수번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
return $this->executeCURL('/Message/' . $ReceiptNum . '/Cancel', $CorpNum, $UserID);
|
||||
}
|
||||
|
||||
/* 예약전송 취소
|
||||
* $CorpNum => 발송사업자번호
|
||||
* $RequestNum=> 전송요청번호
|
||||
* $UserID => 팝빌 회원아이디
|
||||
*/
|
||||
public function CancelReserveRN($CorpNum, $RequestNum, $UserID = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($RequestNum)) {
|
||||
throw new PopbillException('예약전송 취소할 전송요청번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
return $this->executeCURL('/Message/Cancel/' . $RequestNum, $CorpNum, $UserID);
|
||||
}
|
||||
|
||||
/* 예약전송 취소
|
||||
* $CorpNum => 발송사업자번호
|
||||
* $ReceiptNum => 접수번호
|
||||
* $ReceiveNum => 수신번호
|
||||
* $UserID => 팝빌 회원아이디
|
||||
*/
|
||||
public function CancelReservebyRCV($CorpNum, $ReceiptNum, $ReceiveNum, $UserID = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($ReceiptNum)) {
|
||||
throw new PopbillException('예약전송 취소할 접수번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($ReceiveNum)) {
|
||||
throw new PopbillException('예약전송 취소할 수신번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$postdata = json_encode($ReceiveNum);
|
||||
|
||||
return $this->executeCURL('/Message/' . $ReceiptNum . '/Cancel', $CorpNum, $UserID, true, null, $postdata);
|
||||
}
|
||||
|
||||
/* 예약전송 취소
|
||||
* $CorpNum => 발송사업자번호
|
||||
* $RequestNum => 전송요청번호
|
||||
* $ReceiveNum => 수신번호
|
||||
* $UserID => 팝빌 회원아이디
|
||||
*/
|
||||
public function CancelReserveRNbyRCV($CorpNum, $RequestNum, $ReceiveNum, $UserID = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($RequestNum)) {
|
||||
throw new PopbillException('예약전송 취소할 전송요청번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($ReceiveNum)) {
|
||||
throw new PopbillException('예약전송 취소할 수신번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$postdata = json_encode($ReceiveNum);
|
||||
|
||||
return $this->executeCURL('/Message/Cancel/' . $RequestNum, $CorpNum, $UserID, true, null, $postdata);
|
||||
}
|
||||
|
||||
|
||||
private function SendMessage($MessageType, $CorpNum, $Sender, $SenderName, $Subject, $Content, $Messages = array(), $ReserveDT = null, $adsYN = false, $UserID = null, $RequestNum = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($Messages)) {
|
||||
throw new PopbillException('전송할 메시지가 입력되지 않았습니다.');
|
||||
}
|
||||
if(!$this->isNullOrEmpty($ReserveDT) && !$this->isValidDT($ReserveDT)) {
|
||||
throw new PopbillException('전송 예약일시가 유효하지 않습니다.');
|
||||
}
|
||||
|
||||
$Request = array();
|
||||
|
||||
if(!$this->isNullOrEmpty($Sender)) $Request['snd'] = $Sender;
|
||||
if(!$this->isNullOrEmpty($SenderName)) $Request['sndnm'] = $SenderName;
|
||||
if(!$this->isNullOrEmpty($Content)) $Request['content'] = $Content;
|
||||
if(!$this->isNullOrEmpty($Subject)) $Request['subject'] = $Subject;
|
||||
if(!$this->isNullOrEmpty($ReserveDT)) $Request['sndDT'] = $ReserveDT;
|
||||
if(!$this->isNullOrEmpty($RequestNum)) $Request['requestNum'] = $RequestNum;
|
||||
|
||||
if ($adsYN) $Request['adsYN'] = $adsYN;
|
||||
|
||||
$Request['msgs'] = $Messages;
|
||||
|
||||
$postdata = json_encode($Request);
|
||||
return $this->executeCURL('/' . $MessageType, $CorpNum, $UserID, true, null, $postdata)->receiptNum;
|
||||
}
|
||||
|
||||
// 문자 관련 URL함수
|
||||
public function GetURL($CorpNum, $UserID = null, $TOGO)
|
||||
{
|
||||
$response = $this->executeCURL('/Message/?TG=' . $TOGO, $CorpNum, $UserID);
|
||||
return $response->url;
|
||||
}
|
||||
|
||||
// 문자 전송내역 팝업 URL
|
||||
public function GetSentListURL($CorpNum, $UserID = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$response = $this->executeCURL('/Message/?TG=BOX', $CorpNum, $UserID);
|
||||
return $response->url;
|
||||
}
|
||||
|
||||
// 발신번호 관리 팝업 URL
|
||||
public function GetSenderNumberMgtURL($CorpNum, $UserID = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$response = $this->executeCURL('/Message/?TG=SENDER', $CorpNum, $UserID);
|
||||
return $response->url;
|
||||
}
|
||||
|
||||
// 문자 전송내역 조회
|
||||
public function Search($CorpNum, $SDate, $EDate, $State = array(), $Item = array(), $ReserveYN = null, $SenderYN = false, $Page = null, $PerPage = null, $Order = null, $UserID = null, $QString = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($SDate)) {
|
||||
throw new PopbillException('시작일자가 입력되지 않았습니다.');
|
||||
}
|
||||
if(!$this->isValidDate($SDate)) {
|
||||
throw new PopbillException('시작일자가 유효하지 않습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($EDate)) {
|
||||
throw new PopbillException('종료일자가 입력되지 않았습니다.');
|
||||
}
|
||||
if(!$this->isValidDate($EDate)) {
|
||||
throw new PopbillException('종료일자가 유효하지 않습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($State)) {
|
||||
throw new PopbillException('전송상태가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$uri = '/Message/Search';
|
||||
$uri .= '?SDate=' . $SDate;
|
||||
$uri .= '&EDate=' . $EDate;
|
||||
$uri .= '&State=' . implode(',', $State);
|
||||
|
||||
if(!$this->isNullOrEmpty($Item)) {
|
||||
$uri .= '&Item=' . implode(',', $Item);
|
||||
}
|
||||
if(!is_null($ReserveYN)) {
|
||||
if ($ReserveYN) {
|
||||
$uri .= '&ReserveYN=1';
|
||||
} else {
|
||||
$uri .= '&ReserveYN=0';
|
||||
}
|
||||
}
|
||||
if ($SenderYN) {
|
||||
$uri .= '&SenderOnly=1';
|
||||
} else {
|
||||
$uri .= '&SenderOnly=0';
|
||||
}
|
||||
|
||||
if(!$this->isNullOrEmpty($Page)) {
|
||||
$uri .= '&Page=' . $Page;
|
||||
}
|
||||
if(!$this->isNullOrEmpty($PerPage)) {
|
||||
$uri .= '&PerPage=' . $PerPage;
|
||||
}
|
||||
if(!$this->isNullOrEmpty($Order)) {
|
||||
$uri .= '&Order=' . $Order;
|
||||
}
|
||||
if(!$this->isNullOrEmpty($QString)) {
|
||||
$uri .= '&QString=' . urlencode($QString);
|
||||
}
|
||||
|
||||
$response = $this->executeCURL($uri, $CorpNum, $UserID);
|
||||
|
||||
$SearchList = new MsgSearchResult();
|
||||
$SearchList->fromJsonInfo($response);
|
||||
|
||||
return $SearchList;
|
||||
}
|
||||
|
||||
// 080 수신거부목록 조회
|
||||
public function GetAutoDenyList($CorpNum, $UserID = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
return $this->executeCURL('/Message/Denied', $CorpNum, $UserID);
|
||||
}
|
||||
|
||||
// 080 수신거부 조회
|
||||
public function CheckAutoDenyNumber($CorpNum, $UserID = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
return $this->executeCURL('/Message/AutoDenyNumberInfo', $CorpNum, $UserID);
|
||||
}
|
||||
|
||||
public function GetChargeInfo($CorpNum, $MessageType, $UserID = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
if($this->isNullOrEmpty($MessageType)) {
|
||||
throw new PopbillException('문자 전송유형이 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$uri = '/Message/ChargeInfo?Type=' . $MessageType;
|
||||
|
||||
$response = $this->executeCURL($uri, $CorpNum, $UserID);
|
||||
$ChargeInfo = new ChargeInfo();
|
||||
$ChargeInfo->fromJsonInfo($response);
|
||||
|
||||
return $ChargeInfo;
|
||||
}
|
||||
|
||||
// 발신번호 목록 조회
|
||||
public function GetSenderNumberList($CorpNum, $UserID = null)
|
||||
{
|
||||
if($this->isNullOrEmpty($CorpNum)) {
|
||||
throw new PopbillException('팝빌회원 사업자번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
return $this->executeCURL('/Message/SenderNumber', $CorpNum, $UserID);
|
||||
}
|
||||
|
||||
// 문자전송결과
|
||||
public function GetStates($CorpNum, $ReceiptNumList = array(), $UserID = null)
|
||||
{
|
||||
if (is_null($ReceiptNumList) || empty($ReceiptNumList)) {
|
||||
throw new PopbillException('접수번호가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
$postdata = json_encode($ReceiptNumList);
|
||||
$result = $this->executeCURL('/Message/States', $CorpNum, $UserID, true, null, $postdata);
|
||||
$MsgInfoList = array();
|
||||
|
||||
for ($i = 0; $i < Count($result); $i++) {
|
||||
$MsgInfo = new MessageBriefInfo();
|
||||
$MsgInfo->fromJsonInfo($result[$i]);
|
||||
$MsgInfoList[$i] = $MsgInfo;
|
||||
}
|
||||
|
||||
return $MsgInfoList;
|
||||
}
|
||||
}
|
||||
|
||||
class ENumMessageType
|
||||
{
|
||||
const SMS = 'SMS';
|
||||
const LMS = 'LMS';
|
||||
const XMS = 'XMS';
|
||||
const MMS = 'MMS';
|
||||
}
|
||||
|
||||
class MsgSearchResult
|
||||
{
|
||||
public $code;
|
||||
public $total;
|
||||
public $perPage;
|
||||
public $pageNum;
|
||||
public $pageCount;
|
||||
public $message;
|
||||
public $list;
|
||||
|
||||
public function fromJsonInfo($jsonInfo)
|
||||
{
|
||||
isset($jsonInfo->code) ? $this->code = $jsonInfo->code : null;
|
||||
isset($jsonInfo->total) ? $this->total = $jsonInfo->total : null;
|
||||
isset($jsonInfo->perPage) ? $this->perPage = $jsonInfo->perPage : null;
|
||||
isset($jsonInfo->pageCount) ? $this->pageCount = $jsonInfo->pageCount : null;
|
||||
isset($jsonInfo->pageNum) ? $this->pageNum = $jsonInfo->pageNum : null;
|
||||
isset($jsonInfo->message) ? $this->message = $jsonInfo->message : null;
|
||||
|
||||
$InfoList = array();
|
||||
|
||||
for ($i = 0; $i < Count($jsonInfo->list); $i++) {
|
||||
$InfoObj = new MessageInfo();
|
||||
$InfoObj->fromJsonInfo($jsonInfo->list[$i]);
|
||||
$InfoList[$i] = $InfoObj;
|
||||
}
|
||||
$this->list = $InfoList;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MessageInfo
|
||||
{
|
||||
public $state;
|
||||
public $result;
|
||||
public $subject;
|
||||
public $type;
|
||||
public $content;
|
||||
public $tranNet;
|
||||
public $sendNum;
|
||||
public $senderName;
|
||||
public $receiveNum;
|
||||
public $receiveName;
|
||||
public $reserveDT;
|
||||
public $sendDT;
|
||||
public $resultDT;
|
||||
public $sendResult;
|
||||
public $receiptDT;
|
||||
public $receiptNum;
|
||||
public $requestNum;
|
||||
public $interOPRefKey;
|
||||
|
||||
function fromJsonInfo($jsonInfo)
|
||||
{
|
||||
isset($jsonInfo->state) ? $this->state = $jsonInfo->state : null;
|
||||
isset($jsonInfo->result) ? $this->result = $jsonInfo->result : null;
|
||||
isset($jsonInfo->subject) ? $this->subject = $jsonInfo->subject : null;
|
||||
isset($jsonInfo->tranNet) ? $this->tranNet = $jsonInfo->tranNet : null;
|
||||
isset($jsonInfo->type) ? $this->type = $jsonInfo->type : null;
|
||||
isset($jsonInfo->content) ? $this->content = $jsonInfo->content : null;
|
||||
isset($jsonInfo->sendNum) ? $this->sendNum = $jsonInfo->sendNum : null;
|
||||
isset($jsonInfo->senderName) ? $this->senderName = $jsonInfo->senderName : null;
|
||||
isset($jsonInfo->receiveNum) ? $this->receiveNum = $jsonInfo->receiveNum : null;
|
||||
isset($jsonInfo->receiveName) ? $this->receiveName = $jsonInfo->receiveName : null;
|
||||
isset($jsonInfo->reserveDT) ? $this->reserveDT = $jsonInfo->reserveDT : null;
|
||||
isset($jsonInfo->sendDT) ? $this->sendDT = $jsonInfo->sendDT : null;
|
||||
isset($jsonInfo->resultDT) ? $this->resultDT = $jsonInfo->resultDT : null;
|
||||
isset($jsonInfo->sendResult) ? $this->sendResult = $jsonInfo->sendResult : null;
|
||||
isset($jsonInfo->receiptDT) ? $this->receiptDT = $jsonInfo->receiptDT : null;
|
||||
isset($jsonInfo->receiptNum) ? $this->receiptNum = $jsonInfo->receiptNum : null;
|
||||
isset($jsonInfo->requestNum) ? $this->requestNum = $jsonInfo->requestNum : null;
|
||||
isset($jsonInfo->interOPRefKey) ? $this->interOPRefKey = $jsonInfo->interOPRefKey : null;
|
||||
}
|
||||
}
|
||||
|
||||
class MessageBriefInfo
|
||||
{
|
||||
public $sn;
|
||||
public $rNum;
|
||||
public $stat;
|
||||
public $sDT;
|
||||
public $rDT;
|
||||
public $rlt;
|
||||
public $net;
|
||||
public $srt;
|
||||
|
||||
function fromJsonInfo($jsonInfo)
|
||||
{
|
||||
isset($jsonInfo->sn) ? $this->sn = $jsonInfo->sn : null;
|
||||
isset($jsonInfo->rNum) ? $this->rNum = $jsonInfo->rNum : null;
|
||||
isset($jsonInfo->stat) ? $this->stat = $jsonInfo->stat : null;
|
||||
isset($jsonInfo->sDT) ? $this->sDT = $jsonInfo->sDT : null;
|
||||
isset($jsonInfo->rDT) ? $this->rDT = $jsonInfo->rDT : null;
|
||||
isset($jsonInfo->rlt) ? $this->rlt = $jsonInfo->rlt : null;
|
||||
isset($jsonInfo->net) ? $this->net = $jsonInfo->net : null;
|
||||
isset($jsonInfo->srt) ? $this->srt = $jsonInfo->srt : null;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,2 +0,0 @@
|
||||
# popbill.sdk.php5
|
||||
팝빌 SDK for PHP5
|
||||
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
class cryptor {
|
||||
public function encrypt($key, $data) {
|
||||
// 키 설정
|
||||
$publickey = $this->keyInstance($key);
|
||||
|
||||
openssl_public_encrypt($data, $encrypted, $publickey, OPENSSL_PKCS1_OAEP_PADDING);
|
||||
|
||||
return base64_encode($encrypted);
|
||||
}
|
||||
|
||||
public function keyInstance($publickey) {
|
||||
// startline , endline 설정
|
||||
$start_line = "-----BEGIN PUBLIC KEY-----";
|
||||
$end_line = "-----END PUBLIC KEY-----";
|
||||
|
||||
// key 추출 (정규식)
|
||||
$pattern = "/-+([a-zA-Z\s]*)-+([^-]*)-+([a-zA-Z\s]*)-+/";
|
||||
if(preg_match($pattern, $publickey, $matches)) {
|
||||
$splitKey = $matches[2];
|
||||
$splitKey = preg_replace('/\s+/', '', $splitKey);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
$key = "";
|
||||
|
||||
for($pos=1; $pos <= strlen($splitKey); $pos++) {
|
||||
if($pos % 64 == 0) {
|
||||
$key = $key . $splitKey[$pos-1] . "\n";
|
||||
} else {
|
||||
$key = $key . $splitKey[$pos-1];
|
||||
}
|
||||
}
|
||||
|
||||
// startline, endline 추가
|
||||
$key = $start_line . "\n" . $key . "\n" . $end_line;
|
||||
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,930 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* =====================================================================================
|
||||
* Class for base module for Popbill API SDK. It include base functionality for
|
||||
* RESTful web service request and parse json result. It uses Linkhub module
|
||||
* to accomplish authentication APIs.
|
||||
*
|
||||
* This module uses curl and openssl for HTTPS Request. So related modules must
|
||||
* be installed and enabled.
|
||||
*
|
||||
* http://www.linkhub.co.kr
|
||||
* Author : Kim Seongjun
|
||||
* Written : 2014-04-15
|
||||
* Contributor : Jeong YoHan (code@linkhubcorp.com)
|
||||
* Updated : 2025-01-13
|
||||
*
|
||||
* Thanks for your interest.
|
||||
* We welcome any suggestions, feedbacks, blames or anythings.
|
||||
* ======================================================================================
|
||||
*/
|
||||
|
||||
require_once 'Linkhub/linkhub.auth.php';
|
||||
|
||||
class PopbillBase
|
||||
{
|
||||
const ServiceID_REAL = 'POPBILL';
|
||||
const ServiceID_TEST = 'POPBILL_TEST';
|
||||
const ServiceURL_REAL = 'https://popbill.linkhub.co.kr';
|
||||
const ServiceURL_TEST = 'https://popbill-test.linkhub.co.kr';
|
||||
|
||||
const ServiceURL_Static_REAL = 'https://static-popbill.linkhub.co.kr';
|
||||
const ServiceURL_Static_TEST = 'https://static-popbill-test.linkhub.co.kr';
|
||||
|
||||
const ServiceURL_GA_REAL = 'https://ga-popbill.linkhub.co.kr';
|
||||
const ServiceURL_GA_TEST = 'https://ga-popbill-test.linkhub.co.kr';
|
||||
const Version = '1.0';
|
||||
|
||||
private $Token_Table = array();
|
||||
private $Linkhub;
|
||||
private $IsTest = false;
|
||||
private $IPRestrictOnOff = true;
|
||||
private $UseStaticIP = false;
|
||||
private $UseGAIP = false;
|
||||
private $UseLocalTimeYN = true;
|
||||
|
||||
private $scopes = array();
|
||||
private $__requestMode = LINKHUB_COMM_MODE;
|
||||
|
||||
public function __construct($LinkID, $SecretKey)
|
||||
{
|
||||
$this->Linkhub = Linkhub::getInstance($LinkID, $SecretKey);
|
||||
$this->scopes[] = 'member';
|
||||
}
|
||||
|
||||
public function IsTest($T)
|
||||
{
|
||||
$this->IsTest = $T;
|
||||
}
|
||||
|
||||
public function IPRestrictOnOff($V)
|
||||
{
|
||||
$this->IPRestrictOnOff = $V;
|
||||
}
|
||||
|
||||
public function UseStaticIP($V)
|
||||
{
|
||||
$this->UseStaticIP = $V;
|
||||
}
|
||||
|
||||
public function UseGAIP($V)
|
||||
{
|
||||
$this->UseGAIP = $V;
|
||||
}
|
||||
|
||||
public function UseLocalTimeYN($V)
|
||||
{
|
||||
$this->UseLocalTimeYN = $V;
|
||||
}
|
||||
|
||||
protected function AddScope($scope)
|
||||
{
|
||||
$this->scopes[] = $scope;
|
||||
}
|
||||
|
||||
private function getsession_Token($CorpNum)
|
||||
{
|
||||
$targetToken = null;
|
||||
|
||||
if (array_key_exists($CorpNum, $this->Token_Table)) {
|
||||
$targetToken = $this->Token_Table[$CorpNum];
|
||||
}
|
||||
|
||||
$Refresh = false;
|
||||
|
||||
if (is_null($targetToken)) {
|
||||
$Refresh = true;
|
||||
} else {
|
||||
$Expiration = new DateTime($targetToken->expiration, new DateTimeZone("UTC"));
|
||||
|
||||
$now = $this->Linkhub->getTime($this->UseStaticIP, $this->UseLocalTimeYN, $this->UseGAIP);
|
||||
$Refresh = $Expiration < $now;
|
||||
}
|
||||
|
||||
if ($Refresh) {
|
||||
try {
|
||||
$targetToken = $this->Linkhub->getToken($this->IsTest ? PopbillBase::ServiceID_TEST : PopbillBase::ServiceID_REAL, $CorpNum, $this->scopes, $this->IPRestrictOnOff ? null : "*", $this->UseStaticIP, $this->UseLocalTimeYN, $this->UseGAIP);
|
||||
} catch (LinkhubException $le) {
|
||||
throw new PopbillException($le->getMessage(), $le->getCode());
|
||||
}
|
||||
$this->Token_Table[$CorpNum] = $targetToken;
|
||||
}
|
||||
return $targetToken->session_token;
|
||||
}
|
||||
|
||||
// ID 중복 확인
|
||||
public function CheckID($ID)
|
||||
{
|
||||
if (is_null($ID) || empty($ID)) {
|
||||
throw new PopbillException('조회할 아이디가 입력되지 않았습니다.');
|
||||
}
|
||||
return $this->executeCURL('/IDCheck?ID=' . $ID);
|
||||
}
|
||||
|
||||
// 담당자 추가
|
||||
public function RegistContact($CorpNum, $ContactInfo, $UserID = null)
|
||||
{
|
||||
$postdata = json_encode($ContactInfo);
|
||||
return $this->executeCURL('/IDs/New', $CorpNum, $UserID, true, null, $postdata);
|
||||
}
|
||||
|
||||
// 담당자 정보 수정
|
||||
public function UpdateContact($CorpNum, $ContactInfo, $UserID)
|
||||
{
|
||||
$postdata = json_encode($ContactInfo);
|
||||
return $this->executeCURL('/IDs', $CorpNum, $UserID, true, null, $postdata);
|
||||
}
|
||||
|
||||
// 담당자 정보 확인
|
||||
public function GetContactInfo($CorpNum, $ContactID, $UserID = null)
|
||||
{
|
||||
$postdata = '{"id":' . '"' . $ContactID . '"}';
|
||||
return $this->executeCURL('/Contact', $CorpNum, $UserID, true, null, $postdata);
|
||||
}
|
||||
|
||||
// 담당자 목록 조회
|
||||
public function ListContact($CorpNum, $UserID = null)
|
||||
{
|
||||
$ContactInfoList = array();
|
||||
|
||||
$response = $this->executeCURL('/IDs', $CorpNum, $UserID);
|
||||
|
||||
for ($i = 0; $i < Count($response); $i++) {
|
||||
$ContactInfo = new ContactInfo();
|
||||
$ContactInfo->fromJsonInfo($response[$i]);
|
||||
$ContactInfoList[$i] = $ContactInfo;
|
||||
}
|
||||
|
||||
return $ContactInfoList;
|
||||
}
|
||||
|
||||
// 회사정보 확인
|
||||
public function GetCorpInfo($CorpNum, $UserID = null)
|
||||
{
|
||||
$response = $this->executeCURL('/CorpInfo', $CorpNum, $UserID);
|
||||
|
||||
$CorpInfo = new CorpInfo();
|
||||
$CorpInfo->fromJsonInfo($response);
|
||||
return $CorpInfo;
|
||||
}
|
||||
|
||||
// 회사정보 수정
|
||||
public function UpdateCorpInfo($CorpNum, $CorpInfo, $UserID = null)
|
||||
{
|
||||
$postdata = json_encode($CorpInfo);
|
||||
return $this->executeCURL('/CorpInfo', $CorpNum, $UserID, true, null, $postdata);
|
||||
}
|
||||
|
||||
//팝빌 연결 URL함수
|
||||
public function GetPopbillURL($CorpNum, $UserID, $TOGO)
|
||||
{
|
||||
$response = $this->executeCURL('/Member?TG=' . $TOGO, $CorpNum, $UserID);
|
||||
return $response->url;
|
||||
}
|
||||
|
||||
//팝빌 로그인 URL
|
||||
public function GetAccessURL($CorpNum, $UserID)
|
||||
{
|
||||
$response = $this->executeCURL('/Member?TG=LOGIN', $CorpNum, $UserID);
|
||||
return $response->url;
|
||||
}
|
||||
|
||||
// 연동회원 포인트 충전 팝업 URL
|
||||
public function GetChargeURL($CorpNum, $UserID)
|
||||
{
|
||||
$response = $this->executeCURL('/Member?TG=CHRG', $CorpNum, $UserID);
|
||||
return $response->url;
|
||||
}
|
||||
|
||||
// 연동회원 포인트 결제내역 팝업 URL
|
||||
public function GetPaymentURL($CorpNum, $UserID)
|
||||
{
|
||||
$response = $this->executeCURL('/Member?TG=PAYMENT', $CorpNum, $UserID);
|
||||
return $response->url;
|
||||
}
|
||||
|
||||
// 연동회원 포인트 사용내역 팝업 URL
|
||||
public function GetUseHistoryURL($CorpNum, $UserID)
|
||||
{
|
||||
$response = $this->executeCURL('/Member?TG=USEHISTORY', $CorpNum, $UserID);
|
||||
return $response->url;
|
||||
}
|
||||
|
||||
//가입여부 확인
|
||||
public function CheckIsMember($CorpNum, $LinkID)
|
||||
{
|
||||
return $this->executeCURL('/Join?CorpNum=' . $CorpNum . '&LID=' . $LinkID);
|
||||
}
|
||||
|
||||
//회원가입
|
||||
public function JoinMember($JoinForm)
|
||||
{
|
||||
$postdata = json_encode($JoinForm);
|
||||
return $this->executeCURL('/Join', null, null, true, null, $postdata);
|
||||
}
|
||||
|
||||
// 연동회원 잔여포인트 확인
|
||||
public function GetBalance($CorpNum)
|
||||
{
|
||||
try {
|
||||
return $this->Linkhub->getBalance($this->getsession_Token($CorpNum), $this->IsTest ? PopbillBase::ServiceID_TEST : PopbillBase::ServiceID_REAL, $this->UseStaticIP, $this->UseGAIP);
|
||||
} catch (LinkhubException $le) {
|
||||
throw new PopbillException($le->getMessage(), $le->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
// 연동회원 포인트 사용내역 확인
|
||||
public function GetUseHistory($CorpNum, $SDate, $EDate, $Page = null, $PerPage = null, $Order = null, $UserID = null)
|
||||
{
|
||||
$uri = '/UseHistory';
|
||||
$uri .= '?SDate=' . $SDate;
|
||||
$uri .= '&EDate=' . $EDate;
|
||||
$uri .= '&Page=' . $Page;
|
||||
$uri .= '&PerPage=' . $PerPage;
|
||||
$uri .= '&Order=' . $Order;
|
||||
$response = $this->executeCURL($uri, $CorpNum, $UserID);
|
||||
|
||||
$UseHistoryResult = new UseHistoryResult();
|
||||
$UseHistoryResult->fromJsonInfo($response);
|
||||
|
||||
return $UseHistoryResult;
|
||||
}
|
||||
|
||||
// 연동회원 포인트 결제내역 확인
|
||||
public function GetPaymentHistory($CorpNum, $SDate, $EDate, $Page = null, $PerPage = null, $UserID = null)
|
||||
{
|
||||
$uri = '/PaymentHistory';
|
||||
$uri .= '?SDate=' . $SDate;
|
||||
$uri .= '&EDate=' . $EDate;
|
||||
$uri .= '&Page=' . $Page;
|
||||
$uri .= '&PerPage=' . $PerPage;
|
||||
$response = $this->executeCURL($uri, $CorpNum, $UserID);
|
||||
|
||||
$PaymentHistoryResult = new PaymentHistoryResult();
|
||||
$PaymentHistoryResult->fromJsonInfo($response);
|
||||
|
||||
return $PaymentHistoryResult;
|
||||
}
|
||||
|
||||
// 연동회원 포인트 환불내역 확인
|
||||
public function GetRefundHistory($CorpNum, $Page = null, $PerPage = null, $UserID = null)
|
||||
{
|
||||
$uri = '/RefundHistory';
|
||||
$uri .= '?Page=' . $Page;
|
||||
$uri .= '&PerPage=' . $PerPage;
|
||||
$response = $this->executeCURL($uri, $CorpNum, $UserID);
|
||||
|
||||
$RefundHistoryResult = new RefundHistoryResult();
|
||||
$RefundHistoryResult->fromJsonInfo($response);
|
||||
|
||||
return $RefundHistoryResult;
|
||||
}
|
||||
|
||||
// 연동회원 포인트 환불신청
|
||||
public function Refund($CorpNum, $RefundForm, $UserID = null)
|
||||
{
|
||||
$postdata = json_encode($RefundForm);
|
||||
|
||||
return $this->executeCURL('/Refund', $CorpNum, $UserID, true, null, $postdata);
|
||||
}
|
||||
|
||||
// 연동회원 무통장 입금신청
|
||||
public function PaymentRequest($CorpNum, $PaymentForm, $UserID = null)
|
||||
{
|
||||
$postdata = json_encode($PaymentForm);
|
||||
|
||||
return $this->executeCURL('/Payment', $CorpNum, $UserID, true, null, $postdata);
|
||||
}
|
||||
|
||||
// 연동회원 무통장 입금신청 정보확인
|
||||
public function GetSettleResult($CorpNum, $SettleCode, $UserID = null)
|
||||
{
|
||||
$uri = '/Payment/' . $SettleCode;
|
||||
$response = $this->executeCURL($uri, $CorpNum, $UserID);
|
||||
|
||||
$PaymentHistory = new PaymentHistory();
|
||||
$PaymentHistory->fromJsonInfo($response);
|
||||
|
||||
return $PaymentHistory;
|
||||
}
|
||||
|
||||
// 파트너 포인트충전 팝업 URL
|
||||
// - 2017/08/29 추가
|
||||
public function GetPartnerURL($CorpNum, $TOGO)
|
||||
{
|
||||
try {
|
||||
return $this->Linkhub->getPartnerURL($this->getsession_Token($CorpNum), $this->IsTest ? PopbillBase::ServiceID_TEST : PopbillBase::ServiceID_REAL, $TOGO, $this->UseStaticIP, $this->UseGAIP);
|
||||
} catch (LinkhubException $le) {
|
||||
throw new PopbillException($le->getMessage(), $le->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
// 파트너 잔여포인트 확인
|
||||
public function GetPartnerBalance($CorpNum)
|
||||
{
|
||||
try {
|
||||
return $this->Linkhub->getPartnerBalance($this->getsession_Token($CorpNum), $this->IsTest ? PopbillBase::ServiceID_TEST : PopbillBase::ServiceID_REAL, $this->UseStaticIP, $this->UseGAIP);
|
||||
} catch (LinkhubException $le) {
|
||||
throw new PopbillException($le->getMessage(), $le->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
// 회원 탈퇴
|
||||
public function QuitMember($CorpNum, $QuitReason, $UserID = null)
|
||||
{
|
||||
$postData = json_encode(array("quitReason" => $QuitReason));
|
||||
try {
|
||||
$response = $this->executeCURL('/QuitRequest', $CorpNum, $UserID, true, null, $postData);
|
||||
if($response->code == 1) {
|
||||
unset($this-> Token_Table[$CorpNum]);
|
||||
}
|
||||
} catch (LinkhubException $le) {
|
||||
throw new PopbillException($le->getMessage(), $le->getCode());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
// 환불가능 포인트 조회
|
||||
public function GetRefundableBalance($CorpNum, $UserID = null)
|
||||
{
|
||||
return $this->executeCURL('/RefundPoint', $CorpNum, $UserID, false, null)->refundableBalance;
|
||||
}
|
||||
|
||||
// 환불 신청 상태 조회
|
||||
public function GetRefundInfo($CorpNum, $RefundCode, $UserID = null)
|
||||
{
|
||||
if (is_null($RefundCode) || empty($RefundCode)) {
|
||||
throw new PopbillException('조회할 환불코드가 입력되지 않았습니다.');
|
||||
}
|
||||
return $this->executeCURL('/Refund/' . $RefundCode, $CorpNum, $UserID, false, null, null);
|
||||
}
|
||||
|
||||
protected function executeCURL($uri, $CorpNum = null, $userID = null, $isPost = false, $action = null, $postdata = null, $isMultiPart = false, $contentsType = null, $isBinary = false, $SubmitID = null)
|
||||
{
|
||||
if ($this->__requestMode != "STREAM") {
|
||||
|
||||
$targetURL = $this->getTargetURL();
|
||||
|
||||
$http = curl_init($targetURL . $uri);
|
||||
$header = array();
|
||||
|
||||
$header[] = 'User-Agent: PHP5 POPBILL SDK';
|
||||
if (is_null($CorpNum) == false) {
|
||||
$header[] = 'Authorization: Bearer ' . $this->getsession_Token($CorpNum);
|
||||
}
|
||||
if (is_null($userID) == false) {
|
||||
$header[] = 'x-pb-userid: ' . $userID;
|
||||
}
|
||||
if (is_null($action) == false) {
|
||||
$header[] = 'X-HTTP-Method-Override: ' . $action;
|
||||
if ($action == 'BULKISSUE') {
|
||||
$header[] = 'x-pb-message-digest: ' . base64_encode(hash('sha1', $postdata, true));
|
||||
$header[] = 'x-pb-submit-id: ' . $SubmitID;
|
||||
}
|
||||
}
|
||||
|
||||
if ($isMultiPart == false) {
|
||||
if (is_null($contentsType) == false) {
|
||||
$header[] = 'Content-Type: ' . $contentsType;
|
||||
} else {
|
||||
$header[] = 'Content-Type: Application/json';
|
||||
}
|
||||
} else {
|
||||
if ($isBinary) {
|
||||
$boundary = md5(time());
|
||||
$header[] = "Content-Type: multipart/form-data; boundary=" . $boundary;
|
||||
$postbody = $this->binaryPostbody($boundary, $postdata);
|
||||
} else {
|
||||
// PHP 5.6 이상 CURL 파일전송 처리
|
||||
if ((version_compare(PHP_VERSION, '5.5') >= 0)) {
|
||||
curl_setopt($http, CURLOPT_SAFE_UPLOAD, true);
|
||||
foreach ($postdata as $key => $value) {
|
||||
if (strpos($value, '@') === 0) {
|
||||
$filename = ltrim($value, '@');
|
||||
if ($key == 'Filedata') {
|
||||
$filename = substr($filename, 0, strpos($filename, ';filename'));
|
||||
}
|
||||
$displayName = substr($value, strpos($value, 'filename=') + strlen('filename='));
|
||||
$postdata[$key] = new CURLFile($filename, null, $displayName);
|
||||
}
|
||||
} // end of foreach
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($isPost) {
|
||||
curl_setopt($http, CURLOPT_POST, 1);
|
||||
if ($isBinary) {
|
||||
curl_setopt($http, CURLOPT_POSTFIELDS, $postbody);
|
||||
} else {
|
||||
curl_setopt($http, CURLOPT_POSTFIELDS, $postdata);
|
||||
}
|
||||
}
|
||||
|
||||
curl_setopt($http, CURLOPT_HTTPHEADER, $header);
|
||||
curl_setopt($http, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
curl_setopt($http, CURLOPT_ENCODING, 'gzip,deflate');
|
||||
// Connection timeout 설정
|
||||
curl_setopt($http, CURLOPT_CONNECTTIMEOUT_MS, 10 * 1000);
|
||||
// 통합 timeout 설정
|
||||
curl_setopt($http, CURLOPT_TIMEOUT_MS, 180 * 1000);
|
||||
|
||||
$responseJson = curl_exec($http);
|
||||
|
||||
// curl Error 추가
|
||||
if ($responseJson == false) {
|
||||
throw new PopbillException(curl_error($http));
|
||||
}
|
||||
|
||||
$http_status = curl_getinfo($http, CURLINFO_HTTP_CODE);
|
||||
|
||||
$is_gzip = 0 === mb_strpos($responseJson, "\x1f" . "\x8b" . "\x08");
|
||||
|
||||
if ($is_gzip) {
|
||||
$responseJson = $this->Linkhub->gzdecode($responseJson);
|
||||
}
|
||||
|
||||
$contentType = strtolower(curl_getinfo($http, CURLINFO_CONTENT_TYPE));
|
||||
|
||||
curl_close($http);
|
||||
if ($http_status != 200) {
|
||||
throw new PopbillException($responseJson);
|
||||
}
|
||||
|
||||
if (0 === mb_strpos($contentType, 'application/pdf')) {
|
||||
return $responseJson;
|
||||
}
|
||||
|
||||
return json_decode($responseJson);
|
||||
} else {
|
||||
$header = array();
|
||||
|
||||
$header[] = 'Accept-Encoding: gzip,deflate';
|
||||
$header[] = 'Connection: close';
|
||||
$header[] = 'User-Agent: PHP5 POPBILL SDK';
|
||||
if (is_null($CorpNum) == false) {
|
||||
$header[] = 'Authorization: Bearer ' . $this->getsession_Token($CorpNum);
|
||||
}
|
||||
if (is_null($userID) == false) {
|
||||
$header[] = 'x-pb-userid: ' . $userID;
|
||||
}
|
||||
if (is_null($action) == false) {
|
||||
$header[] = 'X-HTTP-Method-Override: ' . $action;
|
||||
if ($action == 'BULKISSUE') {
|
||||
$header[] = 'x-pb-message-digest: ' . base64_encode(hash('sha1', $postdata, true));
|
||||
$header[] = 'x-pb-submit-id: ' . $SubmitID;
|
||||
}
|
||||
}
|
||||
if ($isMultiPart == false) {
|
||||
if (is_null($contentsType) == false) {
|
||||
$header[] = 'Content-Type: ' . $contentsType;
|
||||
} else {
|
||||
$header[] = 'Content-Type: Application/json';
|
||||
}
|
||||
$postbody = $postdata;
|
||||
} else { //Process MultipartBody.
|
||||
$eol = "\r\n";
|
||||
$mime_boundary = md5(time());
|
||||
$header[] = "Content-Type: multipart/form-data; boundary=" . $mime_boundary . $eol;
|
||||
if ($isBinary) {
|
||||
$postbody = $this->binaryPostbody($mime_boundary, $postdata);
|
||||
} else {
|
||||
$postbody = '';
|
||||
if (array_key_exists('form', $postdata)) {
|
||||
$postbody .= '--' . $mime_boundary . $eol;
|
||||
$postbody .= 'content-disposition: form-data; name="form"' . $eol;
|
||||
$postbody .= 'content-type: Application/json;' . $eol . $eol;
|
||||
$postbody .= $postdata['form'] . $eol;
|
||||
foreach ($postdata as $key => $value) {
|
||||
if (substr($key, 0, 4) == 'file') {
|
||||
if (substr($value, 0, 1) == '@') {
|
||||
$value = substr($value, 1);
|
||||
}
|
||||
if (file_exists($value) == FALSE) {
|
||||
throw new PopbillException("전송할 파일이 존재하지 않습니다.", -99999999);
|
||||
}
|
||||
$displayName = substr($value, strpos($value, 'filename=') + strlen('filename='));
|
||||
$fileContents = file_get_contents($value);
|
||||
$postbody .= '--' . $mime_boundary . $eol;
|
||||
$postbody .= "Content-Disposition: form-data; name=\"file\"; filename=\"" .$displayName . "\"" . $eol;
|
||||
$postbody .= "Content-Type: Application/octet-stream" . $eol . $eol;
|
||||
$postbody .= $fileContents . $eol;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists('Filedata', $postdata)) {
|
||||
$postbody .= '--' . $mime_boundary . $eol;
|
||||
if (substr($postdata['Filedata'], 0, 1) == '@') {
|
||||
$value = substr($postdata['Filedata'], 1);
|
||||
$splitStr = explode(';', $value);
|
||||
$path = $splitStr[0];
|
||||
$fileName = substr($splitStr[1], 9);
|
||||
}
|
||||
if (file_exists($path) == FALSE) {
|
||||
throw new PopbillException("전송할 파일이 존재하지 않습니다.", -99999999);
|
||||
}
|
||||
$fileContents = file_get_contents($path);
|
||||
$postbody .= 'content-disposition: form-data; name="Filedata"; filename="' . $this->GetBasename($fileName) . '"' . $eol;
|
||||
$postbody .= 'content-type: Application/octet-stream;' . $eol . $eol;
|
||||
$postbody .= $fileContents . $eol;
|
||||
}
|
||||
$postbody .= '--' . $mime_boundary . '--' . $eol;
|
||||
}
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'http' => array(
|
||||
'ignore_errors' => TRUE,
|
||||
'protocol_version' => '1.0',
|
||||
'method' => 'GET',
|
||||
'timeout' => 180
|
||||
)
|
||||
);
|
||||
|
||||
if ($isPost) {
|
||||
$params['http']['method'] = 'POST';
|
||||
$params['http']['content'] = $postbody;
|
||||
}
|
||||
|
||||
|
||||
if ($header !== null) {
|
||||
$head = "";
|
||||
foreach ($header as $h) {
|
||||
$head = $head . $h . "\r\n";
|
||||
}
|
||||
$params['http']['header'] = substr($head, 0, -2);
|
||||
}
|
||||
|
||||
$ctx = stream_context_create($params);
|
||||
|
||||
$targetURL = $this->getTargetURL();
|
||||
|
||||
$response = file_get_contents($targetURL . $uri, false, $ctx);
|
||||
|
||||
$is_gzip = 0 === mb_strpos($response, "\x1f" . "\x8b" . "\x08");
|
||||
|
||||
if ($is_gzip) {
|
||||
$response = $this->Linkhub->gzdecode($response);
|
||||
}
|
||||
|
||||
if ($http_response_header[0] != "HTTP/1.1 200 OK") {
|
||||
throw new PopbillException($response);
|
||||
}
|
||||
|
||||
foreach ($http_response_header as $k => $v) {
|
||||
$t = explode(':', $v, 2);
|
||||
if (preg_match('/^Content-Type:/i', $v, $out)) {
|
||||
$contentType = trim($t[1]);
|
||||
if (0 === mb_strpos($contentType, 'application/pdf')) {
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return json_decode($response);
|
||||
}
|
||||
}
|
||||
// build multipart/formdata , multipart 폼데이터 만들기
|
||||
protected function binaryPostbody($mime_boundary, $postdata)
|
||||
{
|
||||
$postbody = '';
|
||||
$eol = "\r\n";
|
||||
$postbody .= "--" . $mime_boundary . $eol
|
||||
. 'Content-Disposition: form-data; name="form"' . $eol . $eol . $postdata['form'] . $eol;
|
||||
|
||||
foreach ($postdata as $key => $value) {
|
||||
if (substr($key, 0, 4) == 'name') {
|
||||
$fileName = $value;
|
||||
}
|
||||
if (substr($key, 0, 4) == 'file') {
|
||||
$postbody .= "--" . $mime_boundary . $eol
|
||||
. 'Content-Disposition: form-data; name="' . 'file' . '"; filename="' . $fileName . '"' . $eol
|
||||
. 'Content-Type: Application/octetstream' . $eol . $eol;
|
||||
$postbody .= $value . $eol;
|
||||
}
|
||||
}
|
||||
$postbody .= "--" . $mime_boundary . "--" . $eol;
|
||||
|
||||
return $postbody;
|
||||
}
|
||||
|
||||
//파일명 추출
|
||||
protected function GetBasename($path)
|
||||
{
|
||||
$pattern = '/[^\/\\\\]*$/';
|
||||
if (preg_match($pattern, $path, $matches)) {
|
||||
return $matches[0];
|
||||
}
|
||||
throw new PopbillException("파일명 추출에 실패 하였습니다.", -99999999);
|
||||
}
|
||||
|
||||
// 서비스 URL
|
||||
private function getTargetURL()
|
||||
{
|
||||
if ($this->UseGAIP) {
|
||||
return ($this->IsTest ? PopbillBase::ServiceURL_GA_TEST : PopbillBase::ServiceURL_GA_REAL);
|
||||
} else if ($this->UseStaticIP) {
|
||||
return ($this->IsTest ? PopbillBase::ServiceURL_Static_TEST : PopbillBase::ServiceURL_Static_REAL);
|
||||
} else {
|
||||
return ($this->IsTest ? PopbillBase::ServiceURL_TEST : PopbillBase::ServiceURL_REAL);
|
||||
}
|
||||
}
|
||||
|
||||
public function isNullOrEmpty($value)
|
||||
{
|
||||
if(is_bool($value)) {
|
||||
return is_null($value) || $value === '';
|
||||
}
|
||||
return is_null($value) || empty($value);
|
||||
}
|
||||
|
||||
public function isValidDate($date)
|
||||
{
|
||||
return preg_match('/(\d{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])/', $date);
|
||||
}
|
||||
|
||||
public function isValidDT($datetime)
|
||||
{
|
||||
return preg_match('/(\d{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])(0[0-9]|1[0-9]|2[0-3])([0-5][0-9])([0-5][0-9])/', $datetime);
|
||||
}
|
||||
}
|
||||
|
||||
class JoinForm
|
||||
{
|
||||
public $LinkID;
|
||||
public $CorpNum;
|
||||
public $CEOName;
|
||||
public $CorpName;
|
||||
public $Addr;
|
||||
public $ZipCode;
|
||||
public $BizType;
|
||||
public $BizClass;
|
||||
public $ContactName;
|
||||
public $ContactEmail;
|
||||
public $ContactTEL;
|
||||
public $contactHP;
|
||||
public $contactFAX;
|
||||
public $ID;
|
||||
public $PWD;
|
||||
public $Password;
|
||||
}
|
||||
|
||||
class UseHistoryResult
|
||||
{
|
||||
public $code;
|
||||
public $total;
|
||||
public $perPage;
|
||||
public $pageNum;
|
||||
public $pageCount;
|
||||
public $list;
|
||||
|
||||
public function fromJsonInfo($jsonInfo)
|
||||
{
|
||||
isset($jsonInfo->code) ? $this->code = $jsonInfo->code : null;
|
||||
isset($jsonInfo->total) ? $this->total = $jsonInfo->total : null;
|
||||
isset($jsonInfo->perPage) ? $this->perPage = $jsonInfo->perPage : null;
|
||||
isset($jsonInfo->pageNum) ? $this->pageNum = $jsonInfo->pageNum : null;
|
||||
isset($jsonInfo->pageCount) ? $this->pageCount = $jsonInfo->pageCount : null;
|
||||
|
||||
$HistoryList = array();
|
||||
|
||||
for ($i = 0; $i < Count($jsonInfo->list); $i++) {
|
||||
$HistoryObj = new UseHistory();
|
||||
$HistoryObj->fromJsonInfo($jsonInfo->list[$i]);
|
||||
$HistoryList[$i] = $HistoryObj;
|
||||
}
|
||||
$this->list = $HistoryList;
|
||||
}
|
||||
}
|
||||
|
||||
class UseHistory
|
||||
{
|
||||
public $itemCode;
|
||||
public $txType;
|
||||
public $txPoint;
|
||||
public $balance;
|
||||
public $txDT;
|
||||
public $userID;
|
||||
public $userName;
|
||||
|
||||
public function fromJsonInfo($jsonInfo)
|
||||
{
|
||||
isset($jsonInfo->itemCode) ? $this->itemCode = $jsonInfo->itemCode : null;
|
||||
isset($jsonInfo->txType) ? $this->txType = $jsonInfo->txType : null;
|
||||
isset($jsonInfo->txPoint) ? $this->txPoint = $jsonInfo->txPoint : null;
|
||||
isset($jsonInfo->balance) ? $this->balance = $jsonInfo->balance : null;
|
||||
isset($jsonInfo->txDT) ? $this->txDT = $jsonInfo->txDT : null;
|
||||
isset($jsonInfo->userID) ? $this->userID = $jsonInfo->userID : null;
|
||||
isset($jsonInfo->userName) ? $this->userName = $jsonInfo->userName : null;
|
||||
}
|
||||
}
|
||||
|
||||
class PaymentHistoryResult
|
||||
{
|
||||
public $code;
|
||||
public $total;
|
||||
public $perPage;
|
||||
public $pageNum;
|
||||
public $pageCount;
|
||||
public $list;
|
||||
|
||||
public function fromJsonInfo($jsonInfo)
|
||||
{
|
||||
isset($jsonInfo->code) ? $this->code = $jsonInfo->code : null;
|
||||
isset($jsonInfo->total) ? $this->total = $jsonInfo->total : null;
|
||||
isset($jsonInfo->perPage) ? $this->perPage = $jsonInfo->perPage : null;
|
||||
isset($jsonInfo->pageNum) ? $this->pageNum = $jsonInfo->pageNum : null;
|
||||
isset($jsonInfo->pageCount) ? $this->pageCount = $jsonInfo->pageCount : null;
|
||||
|
||||
$HistoryList = array();
|
||||
|
||||
for ($i = 0; $i < Count($jsonInfo->list); $i++) {
|
||||
$HistoryObj = new PaymentHistory();
|
||||
$HistoryObj->fromJsonInfo($jsonInfo->list[$i]);
|
||||
$HistoryList[$i] = $HistoryObj;
|
||||
}
|
||||
$this->list = $HistoryList;
|
||||
}
|
||||
}
|
||||
|
||||
class PaymentHistory
|
||||
{
|
||||
public $productType;
|
||||
public $productName;
|
||||
public $settleType;
|
||||
public $settlerName;
|
||||
public $settlerEmail;
|
||||
public $settleCost;
|
||||
public $settlePoint;
|
||||
public $settleState;
|
||||
public $regDT;
|
||||
public $stateDT;
|
||||
|
||||
public function fromJsonInfo($jsonInfo)
|
||||
{
|
||||
isset($jsonInfo->productType) ? $this->productType = $jsonInfo->productType : null;
|
||||
isset($jsonInfo->productName) ? $this->productName = $jsonInfo->productName : null;
|
||||
isset($jsonInfo->settleType) ? $this->settleType = $jsonInfo->settleType : null;
|
||||
isset($jsonInfo->settlerName) ? $this->settlerName = $jsonInfo->settlerName : null;
|
||||
isset($jsonInfo->settlerEmail) ? $this->settlerEmail = $jsonInfo->settlerEmail : null;
|
||||
isset($jsonInfo->settleCost) ? $this->settleCost = $jsonInfo->settleCost : null;
|
||||
isset($jsonInfo->settlePoint) ? $this->settlePoint = $jsonInfo->settlePoint : null;
|
||||
isset($jsonInfo->settleState) ? $this->settleState = $jsonInfo->settleState : null;
|
||||
isset($jsonInfo->regDT) ? $this->regDT = $jsonInfo->regDT : null;
|
||||
isset($jsonInfo->stateDT) ? $this->stateDT = $jsonInfo->stateDT : null;
|
||||
}
|
||||
}
|
||||
|
||||
class RefundHistoryResult
|
||||
{
|
||||
public $code;
|
||||
public $total;
|
||||
public $perPage;
|
||||
public $pageNum;
|
||||
public $pageCount;
|
||||
public $list;
|
||||
|
||||
public function fromJsonInfo($jsonInfo)
|
||||
{
|
||||
isset($jsonInfo->code) ? $this->code = $jsonInfo->code : null;
|
||||
isset($jsonInfo->total) ? $this->total = $jsonInfo->total : null;
|
||||
isset($jsonInfo->perPage) ? $this->perPage = $jsonInfo->perPage : null;
|
||||
isset($jsonInfo->pageNum) ? $this->pageNum = $jsonInfo->pageNum : null;
|
||||
isset($jsonInfo->pageCount) ? $this->pageCount = $jsonInfo->pageCount : null;
|
||||
|
||||
$HistoryList = array();
|
||||
|
||||
for ($i = 0; $i < Count($jsonInfo->list); $i++) {
|
||||
$HistoryObj = new RefundHistory();
|
||||
$HistoryObj->fromJsonInfo($jsonInfo->list[$i]);
|
||||
$HistoryList[$i] = $HistoryObj;
|
||||
}
|
||||
$this->list = $HistoryList;
|
||||
}
|
||||
}
|
||||
|
||||
class RefundHistory
|
||||
{
|
||||
public $reqDT;
|
||||
public $requestPoint;
|
||||
public $accountBank;
|
||||
public $accountNum;
|
||||
public $accountName;
|
||||
public $state;
|
||||
public $reason;
|
||||
|
||||
public function fromJsonInfo($jsonInfo)
|
||||
{
|
||||
isset($jsonInfo->reqDT) ? $this->reqDT = $jsonInfo->reqDT : null;
|
||||
isset($jsonInfo->requestPoint) ? $this->requestPoint = $jsonInfo->requestPoint : null;
|
||||
isset($jsonInfo->accountBank) ? $this->accountBank = $jsonInfo->accountBank : null;
|
||||
isset($jsonInfo->accountNum) ? $this->accountNum = $jsonInfo->accountNum : null;
|
||||
isset($jsonInfo->accountName) ? $this->accountName = $jsonInfo->accountName : null;
|
||||
isset($jsonInfo->state) ? $this->state = $jsonInfo->state : null;
|
||||
isset($jsonInfo->reason) ? $this->reason = $jsonInfo->reason : null;
|
||||
}
|
||||
}
|
||||
|
||||
class PaymentForm
|
||||
{
|
||||
public $settlerName;
|
||||
public $settlerEmail;
|
||||
public $notifyHP;
|
||||
public $paymentName;
|
||||
public $settleCost;
|
||||
}
|
||||
|
||||
class RefundForm
|
||||
{
|
||||
public $contactname;
|
||||
public $tel;
|
||||
public $requestpoint;
|
||||
public $accountbank;
|
||||
public $accountnum;
|
||||
public $accountname;
|
||||
public $reason;
|
||||
}
|
||||
|
||||
class CorpInfo
|
||||
{
|
||||
public $ceoname;
|
||||
public $corpName;
|
||||
public $addr;
|
||||
public $bizType;
|
||||
public $bizClass;
|
||||
|
||||
public function fromJsonInfo($jsonInfo)
|
||||
{
|
||||
isset($jsonInfo->ceoname) ? $this->ceoname = $jsonInfo->ceoname : null;
|
||||
isset($jsonInfo->corpName) ? $this->corpName = $jsonInfo->corpName : null;
|
||||
isset($jsonInfo->addr) ? $this->addr = $jsonInfo->addr : null;
|
||||
isset($jsonInfo->bizType) ? $this->bizType = $jsonInfo->bizType : null;
|
||||
isset($jsonInfo->bizClass) ? $this->bizClass = $jsonInfo->bizClass : null;
|
||||
}
|
||||
}
|
||||
|
||||
class ContactInfo
|
||||
{
|
||||
public $id;
|
||||
public $pwd;
|
||||
public $Password;
|
||||
public $email;
|
||||
public $hp;
|
||||
public $personName;
|
||||
public $searchAllAllowYN;
|
||||
public $searchRole;
|
||||
public $tel;
|
||||
public $fax;
|
||||
public $mgrYN;
|
||||
public $regDT;
|
||||
public $state;
|
||||
|
||||
public function fromJsonInfo($jsonInfo)
|
||||
{
|
||||
isset($jsonInfo->id) ? $this->id = $jsonInfo->id : null;
|
||||
isset($jsonInfo->email) ? $this->email = $jsonInfo->email : null;
|
||||
isset($jsonInfo->hp) ? $this->hp = $jsonInfo->hp : null;
|
||||
isset($jsonInfo->personName) ? $this->personName = $jsonInfo->personName : null;
|
||||
isset($jsonInfo->searchAllAllowYN) ? $this->searchAllAllowYN = $jsonInfo->searchAllAllowYN : null;
|
||||
isset($jsonInfo->searchRole) ? $this->searchRole = $jsonInfo->searchRole : null;
|
||||
isset($jsonInfo->tel) ? $this->tel = $jsonInfo->tel : null;
|
||||
isset($jsonInfo->fax) ? $this->fax = $jsonInfo->fax : null;
|
||||
isset($jsonInfo->mgrYN) ? $this->mgrYN = $jsonInfo->mgrYN : null;
|
||||
isset($jsonInfo->regDT) ? $this->regDT = $jsonInfo->regDT : null;
|
||||
isset($jsonInfo->state) ? $this->state = $jsonInfo->state : null;
|
||||
}
|
||||
}
|
||||
|
||||
class ChargeInfo
|
||||
{
|
||||
public $unitCost;
|
||||
public $chargeMethod;
|
||||
public $rateSystem;
|
||||
|
||||
public function fromJsonInfo($jsonInfo)
|
||||
{
|
||||
isset($jsonInfo->unitCost) ? $this->unitCost = $jsonInfo->unitCost : null;
|
||||
isset($jsonInfo->chargeMethod) ? $this->chargeMethod = $jsonInfo->chargeMethod : null;
|
||||
isset($jsonInfo->rateSystem) ? $this->rateSystem = $jsonInfo->rateSystem : null;
|
||||
}
|
||||
}
|
||||
|
||||
class PopbillException extends Exception
|
||||
{
|
||||
public function __construct($response, $code = -99999999, Exception $previous = null)
|
||||
{
|
||||
$Err = json_decode($response);
|
||||
if (is_null($Err)) {
|
||||
parent::__construct($response, $code);
|
||||
} else {
|
||||
parent::__construct($Err->message, $Err->code);
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
|
||||
}
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
// 팝빌 설정값 가져오기
|
||||
$userID = isset($config['cf_popbill_userid']) && $config['cf_popbill_userid'] !== '' ? $config['cf_popbill_userid'] : '';
|
||||
$linkID = isset($config['cf_popbill_link_id']) && $config['cf_popbill_link_id'] !== '' ? $config['cf_popbill_link_id'] : '';
|
||||
$secretKey = isset($config['cf_popbill_secretkey']) && $config['cf_popbill_secretkey'] !== '' ? $config['cf_popbill_secretkey'] : '';
|
||||
$corpnum = isset($config['cf_kakaotalk_corpnum']) && $config['cf_kakaotalk_corpnum'] !== '' ? preg_replace('/[^0-9]/', '', $config['cf_kakaotalk_corpnum']) : '';
|
||||
$sender_hp = isset($config['cf_kakaotalk_sender_hp']) && $config['cf_kakaotalk_sender_hp'] !== '' ? preg_replace('/[^0-9]/', '', $config['cf_kakaotalk_sender_hp']) : '';
|
||||
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
include_once('../../common.php');
|
||||
include_once('./_common.php');
|
||||
include_once(G5_KAKAO5_PATH.'/kakao5.lib.php');
|
||||
|
||||
// 팝빌 정보 확인
|
||||
$check_result = get_popbill_service_info();
|
||||
|
||||
if (isset($check_result['error'])) {
|
||||
die(json_encode(array('error' => $check_result['error'])));
|
||||
} else {
|
||||
$charge_url = get_popbill_point_URL(); // 포인트 충전 팝업 URL
|
||||
die(json_encode(array('balance' => $check_result['balance'], 'charge_url' => $charge_url)));
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
/* 팝빌 URL 출력 */
|
||||
include_once('../../common.php');
|
||||
include_once('./_common.php');
|
||||
include_once(G5_KAKAO5_PATH.'/kakao5.lib.php'); // 팝빌 카카오톡 솔루션 라이브러리
|
||||
|
||||
$url = null;
|
||||
$width = '1200';
|
||||
$height = '800';
|
||||
$get_url = isset($_POST['get_url']) ? $_POST['get_url'] : null;
|
||||
|
||||
if ($config['cf_kakaotalk_use'] == 'popbill') {
|
||||
switch ($get_url) {
|
||||
case '1': // 템플릿 목록 URL
|
||||
$url = get_popbill_template_manage_URL();
|
||||
break;
|
||||
case '2': // 전송내역 URL
|
||||
$url = get_popbill_send_manage_URL();
|
||||
$width = '1350';
|
||||
break;
|
||||
case '3': // 플러스친구 관리 URL
|
||||
$url = get_popbill_plusfriend_manage_URL();
|
||||
break;
|
||||
case '4': // 발신번호 등록 URL
|
||||
$url = get_popbill_sender_number_URL();
|
||||
break;
|
||||
case '5': // 포인트 충전 URL
|
||||
$url = get_popbill_point_URL();
|
||||
$width = '800';
|
||||
$height = '700';
|
||||
break;
|
||||
default:
|
||||
$url = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('url' => $url, 'width' => $width, 'height' => $height)));
|
||||
@ -1,449 +0,0 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
include_once(G5_KAKAO5_PATH.'/_common.php');
|
||||
require_once(G5_KAKAO5_PATH.'/kakao5_popbill.lib.php');
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
** 알림톡 함수 모음
|
||||
**
|
||||
*************************************************************************/
|
||||
/**
|
||||
* 프리셋 코드를 사용하여 알림톡을 전송하는 함수
|
||||
*/
|
||||
function send_alimtalk_preset($preset_code, array $recipient, $conditions = [])
|
||||
{
|
||||
global $g5, $sender_hp, $member, $config;
|
||||
|
||||
// 알림톡 사용 설정 확인
|
||||
if (empty($config['cf_kakaotalk_use'])) {
|
||||
return array('success' => false, 'msg' => '알림톡 사용이 설정되어 있지 않습니다.');
|
||||
}
|
||||
|
||||
// 프리셋 코드로 프리셋 정보 확인
|
||||
$preset_info = get_alimtalk_preset_info($preset_code);
|
||||
if (isset($preset_info['error'])) {
|
||||
return array('success' => false, 'msg' => $preset_info['error'], 'data' => $preset_info);
|
||||
}
|
||||
$template_code = $preset_info['template_code']; // 템플릿 코드
|
||||
|
||||
// 수신자 정리 (전화번호 숫자만)
|
||||
$receiver_hp = preg_replace('/[^0-9]/', '', $recipient['rcv'] ?? '');
|
||||
$receiver_nm = $recipient['rcvnm'] ?? '';
|
||||
|
||||
// 수신자 정보 배열 구성
|
||||
$messages = [['rcv' => $receiver_hp, 'rcvnm' => $receiver_nm]];
|
||||
|
||||
// 주문내역에서 mb_id 조회
|
||||
if (empty($conditions['mb_id']) && !empty($conditions['od_id'])) {
|
||||
$sql = "SELECT mb_id FROM {$g5['g5_shop_order_table']} WHERE od_id = '" . sql_escape_string($conditions['od_id']) . "' LIMIT 1";
|
||||
$row = sql_fetch($sql);
|
||||
if ($row && !empty($row['mb_id'])) {
|
||||
$conditions['mb_id'] = $row['mb_id'];
|
||||
} else {
|
||||
$conditions['mb_id'] = $member['mb_id'] ?? 'GUEST';
|
||||
}
|
||||
}
|
||||
|
||||
// 전송요청번호 생성
|
||||
$request_num = generate_alimtalk_request_id($conditions['mb_id'], $preset_code);
|
||||
|
||||
// 전송 내역 초기 저장
|
||||
$history_id = save_alimtalk_history($preset_info['preset_id'], $template_code, $preset_info['alt_send'], $request_num, $receiver_nm, $receiver_hp, $conditions['mb_id']);
|
||||
|
||||
// 템플릿 정보 조회
|
||||
$full_template_info = '';
|
||||
if($config['cf_kakaotalk_use'] === 'popbill'){ // 팝빌
|
||||
$full_template_info = get_popbill_template_info($template_code);
|
||||
}
|
||||
|
||||
// 템플릿 정보를 못 불러 올 경우 - 발송 취소
|
||||
if (is_array($full_template_info) && isset($full_template_info['error'])) {
|
||||
// 탬플릿 정보 조회 실패: 알림톡 전송내역 업데이트
|
||||
$messages = "템플릿 정보 조회 실패: ".$full_template_info['error'];
|
||||
update_alimtalk_history($history_id, ['ph_log' => $messages]);
|
||||
return array('success' => false, 'msg' => $messages, 'data' => $full_template_info);
|
||||
}
|
||||
|
||||
// 템플릿 내용 변수 치환
|
||||
$content = replace_alimtalk_content_vars($full_template_info->template, $conditions);
|
||||
|
||||
// 버튼 링크 치환
|
||||
$buttons = set_alimtalk_button_links($full_template_info->btns, $conditions);
|
||||
|
||||
try {
|
||||
// 알림톡 전송 정보
|
||||
$data = [
|
||||
'template_code' => $template_code,
|
||||
'sender_hp' => $sender_hp,
|
||||
'content' => $content,
|
||||
'alt_content' => $content,
|
||||
'alt_send' => ($preset_info['alt_send'] == '1') ? 'C' : null,
|
||||
'messages' => $messages,
|
||||
'reserveDT' => null,
|
||||
'request_num' => $request_num,
|
||||
'buttons' => $buttons,
|
||||
'alt_subject' => $preset_info['preset_name']
|
||||
];
|
||||
|
||||
$receipt_num = '';
|
||||
if ($config['cf_kakaotalk_use'] === 'popbill') { // 팝빌 전송
|
||||
$receipt_num = send_popbill_alimtalk($data);
|
||||
}
|
||||
|
||||
// 전송 결과 처리
|
||||
if ((is_array($receipt_num) && isset($receipt_num['error'])) || empty($receipt_num)) {
|
||||
// 전송 실패: 알림톡 전송내역 업데이트
|
||||
$error_message = is_array($receipt_num) && isset($receipt_num['error']) ? $receipt_num['error'] : '알림톡 전송 결과가 비어 있습니다.';
|
||||
$messages = '알림톡 전송 실패하였습니다.\n' . $error_message;
|
||||
update_alimtalk_history($history_id, ['ph_log' => $messages, 'ph_state' => 2]);
|
||||
return array('success' => false, 'msg' => $messages, 'code' => (is_array($receipt_num) && isset($receipt_num['code']) ? $receipt_num['code'] : null));
|
||||
} else {
|
||||
// 전송 성공: 알림톡 전송내역 업데이트
|
||||
$messages = '알림톡이 정상적으로 전송되었습니다.';
|
||||
update_alimtalk_history($history_id, ['ph_receipt_num' => $receipt_num, 'ph_state' => 1, 'ph_log' => $content]);
|
||||
return array('success' => true, 'msg' => $messages, 'receipt_num' => $receipt_num);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// 전송 오류: 알림톡 전송내역 업데이트
|
||||
$messages = '알림톡 전송 중 오류가 발생하였습니다.\n' . $e->getMessage();
|
||||
update_alimtalk_history($history_id, ['ph_log' => $messages, 'ph_state' => 2]);
|
||||
return array('success' => false, 'msg' => $messages, 'code' => $e->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 프리셋 코드로 프리셋 정보 확인
|
||||
*/
|
||||
function get_alimtalk_preset_info($preset_code)
|
||||
{
|
||||
global $g5;
|
||||
|
||||
if (empty($preset_code)) {
|
||||
return array('error' => '프리셋 코드가 입력되지 않았습니다.');
|
||||
}
|
||||
|
||||
// 프리셋 코드로 프리셋 정보 조회
|
||||
$sql = "SELECT * FROM {$g5['kakao5_preset_table']} WHERE kp_preset_code = '" . sql_escape_string($preset_code) . "'";
|
||||
$preset = sql_fetch($sql);
|
||||
|
||||
if (!$preset) {
|
||||
return array('error' => '해당 프리셋 코드(' . $preset_code . ')가 존재하지 않습니다.');
|
||||
}
|
||||
|
||||
// 활성화 상태 확인
|
||||
if ($preset['kp_active'] != '1') {
|
||||
return array('error' => '프리셋(' . $preset['kp_preset_name'] . ')이 비활성화되어 있습니다.');
|
||||
}
|
||||
|
||||
// 템플릿 코드 확인
|
||||
if (empty($preset['kp_template_name'])) {
|
||||
return array('error' => '프리셋(' . $preset['kp_preset_name'] . ')에 템플릿이 설정되지 않았습니다.');
|
||||
}
|
||||
|
||||
// 모든 조건을 만족하면 프리셋 정보 반환
|
||||
return array(
|
||||
'success' => true,
|
||||
'preset' => $preset,
|
||||
'preset_id' => $preset['kp_id'],
|
||||
'preset_name' => $preset['kp_preset_name'],
|
||||
'preset_code' => $preset['kp_preset_code'],
|
||||
'template_code' => $preset['kp_template_name'],
|
||||
'alt_send' => $preset['kp_alt_send'],
|
||||
'type' => $preset['kp_type']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 템플릿 내용 변수 치환
|
||||
*/
|
||||
function replace_alimtalk_content_vars($content, $conditions = [])
|
||||
{
|
||||
global $g5, $kakao5_preset_variable_list;
|
||||
|
||||
$replacements = [];
|
||||
|
||||
// 1. 템플릿에서 변수 추출
|
||||
if (!preg_match_all('/#\{(.*?)\}/', $content, $matches) || empty($matches[1])) {
|
||||
return $content;
|
||||
}
|
||||
$found_vars = array_unique($matches[1]);
|
||||
|
||||
// 2. 변수 정의 맵 캐싱
|
||||
static $var_info_map = null;
|
||||
if ($var_info_map === null) {
|
||||
$var_info_map = [];
|
||||
foreach ($kakao5_preset_variable_list as $category) {
|
||||
foreach ($category['variables'] as $var) {
|
||||
if (preg_match('/#\{(.*?)\}/', $var['name'], $match) && isset($match[1])) {
|
||||
$var_info_map[$match[1]] = $var;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 쿼리 맵 구성 및 치환값 우선 결정
|
||||
$query_map = [];
|
||||
$var_to_query = [];
|
||||
foreach ($found_vars as $var_name) {
|
||||
$replacement_key = "#{{$var_name}}";
|
||||
|
||||
// 1순위: 변수 정의가 있고, $conditions에 column값이 있으면 바로 치환
|
||||
if (isset($var_info_map[$var_name])) {
|
||||
$var = $var_info_map[$var_name];
|
||||
$column = $var['column'];
|
||||
$table = $g5[$var['table'] ?? ''];
|
||||
$condition_key = $var['condition_key'] ?? '';
|
||||
|
||||
if (isset($conditions[$column])) {
|
||||
$replacements[$replacement_key] = $conditions[$column];
|
||||
continue;
|
||||
}
|
||||
|
||||
// 테이블명에 게시판과 같이 뒤에 붙는 변수가 있을 경우 사용
|
||||
$table_placeholder = isset($var['table_placeholder']) ? trim($var['table_placeholder'], '{}') : '';
|
||||
if ($table_placeholder && !empty($conditions[$table_placeholder])) {
|
||||
$table .= $conditions[$table_placeholder];
|
||||
}
|
||||
|
||||
// 2순위: 변수정의에 따라 DB 조회 필요
|
||||
$where = '';
|
||||
if(!empty($condition_key)) {
|
||||
if (!isset($conditions[$condition_key])) {
|
||||
$replacements[$replacement_key] = '';
|
||||
continue;
|
||||
}
|
||||
$cond_val = sql_escape_string($conditions[$condition_key]);
|
||||
$where = "{$condition_key} = '{$cond_val}'";
|
||||
}
|
||||
$query_key = "{$table}|{$where}";
|
||||
|
||||
if (!isset($query_map[$query_key])) {
|
||||
$query_map[$query_key] = [
|
||||
'table' => $table,
|
||||
'where' => $where,
|
||||
'columns' => [],
|
||||
'is_price' => $var['is_price'] ?? false,
|
||||
];
|
||||
}
|
||||
$query_map[$query_key]['columns'][$var_name] = $column;
|
||||
$var_to_query[$var_name] = $query_key;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 4. 조건값이 없으면 조회 불가 → 빈값
|
||||
$replacements[$replacement_key] = '';
|
||||
}
|
||||
|
||||
// 4. DB 조회 (필요한 경우만)
|
||||
$query_results = [];
|
||||
foreach ($query_map as $query_key => $info) {
|
||||
$table = $info['table'];
|
||||
$where = $info['where'];
|
||||
$columns = array_unique(array_values($info['columns']));
|
||||
$column_sql = implode(',', $columns);
|
||||
|
||||
$sql = "SELECT {$column_sql} FROM {$table}";
|
||||
if (!empty($where)) {
|
||||
$sql .= " WHERE {$where}";
|
||||
}
|
||||
$sql .= " LIMIT 1";
|
||||
$query_results[$query_key] = sql_fetch($sql) ?: [];
|
||||
}
|
||||
|
||||
// 5. DB 결과로 치환값 보완
|
||||
foreach ($found_vars as $var_name) {
|
||||
$replacement_key = "#{{$var_name}}";
|
||||
|
||||
if (isset($replacements[$replacement_key])) continue; // 이미 치환된 값 있음
|
||||
|
||||
if (isset($var_to_query[$var_name])) {
|
||||
$query_key = $var_to_query[$var_name];
|
||||
$column = $query_map[$query_key]['columns'][$var_name];
|
||||
$value = $query_results[$query_key][$column] ?? '';
|
||||
// is_price일경우 숫자(정수 또는 실수)라면 number_format 적용
|
||||
if (isset($var_info_map[$var_name]['is_price']) && $var_info_map[$var_name]['is_price'] && is_numeric($value) && $value !== '') {
|
||||
$value = number_format($value);
|
||||
}
|
||||
$replacements[$replacement_key] = $value;
|
||||
} else {
|
||||
$replacements[$replacement_key] = '';
|
||||
}
|
||||
}
|
||||
|
||||
return strtr($content, $replacements);
|
||||
}
|
||||
|
||||
/**
|
||||
* 버튼 링크 치환
|
||||
*/
|
||||
function set_alimtalk_button_links($btns, $conditions = [])
|
||||
{
|
||||
// [정의] $kakao5_preset_button_links - extend/kakao5.extend.php
|
||||
global $kakao5_preset_button_links;
|
||||
|
||||
$buttons = [];
|
||||
if (!empty($btns)) {
|
||||
foreach ($btns as $idx => $btn) {
|
||||
// 버튼의 u1, u2에 대해 #{...} 플레이스홀더를 찾아 알맞은 URL로 치환
|
||||
foreach (['u1', 'u2'] as $field) {
|
||||
if (isset($btn->$field)) {
|
||||
if (preg_match('/#\{(.*?)\}/', $btn->$field, $match)) {
|
||||
$placeholder = $match[0];
|
||||
if (isset($kakao5_preset_button_links[$placeholder])) {
|
||||
$url = $kakao5_preset_button_links[$placeholder]['url'];
|
||||
// URL 내 {변수} 치환
|
||||
if (preg_match_all('/\{(.*?)\}/', $url, $url_vars)) {
|
||||
foreach ($url_vars[1] as $var_name) {
|
||||
// 치환할 값이 없으면 빈 문자열 처리
|
||||
$replace_val = $conditions[$var_name] ?? '';
|
||||
|
||||
// URL로 쓰일 수 있으므로 안전하게 인코딩
|
||||
$url = str_replace('{' . $var_name . '}', urlencode($replace_val), $url);
|
||||
}
|
||||
}
|
||||
$btn->$field = $url;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$buttons[] = (array)$btn;
|
||||
}
|
||||
}
|
||||
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
* 전송요청번호 생성 (고유성 보장)
|
||||
*/
|
||||
function generate_alimtalk_request_id($mb_id, $preset_code)
|
||||
{
|
||||
$prefix = substr($preset_code, 0, 1); // 사용자 구분
|
||||
$mb_hash = substr(md5($mb_id), 0, 4); // mb_id 해시 4자리
|
||||
$dateTimeStr = date('ymdHis') . sprintf('%03d', (microtime(true) * 1000) % 1000); // 날짜(초) + 마이크로초(밀리초 3자리)
|
||||
$requestNum = "{$prefix}{$mb_hash}{$dateTimeStr}";
|
||||
|
||||
return substr($requestNum, 0, 20);
|
||||
}
|
||||
|
||||
/**
|
||||
* 알림톡 프리셋 전송 이력 저장
|
||||
*/
|
||||
function save_alimtalk_history($preset_id, $template_code, $alt_send, $request_num, $rcvnm, $rcv, $mb_id = '')
|
||||
{
|
||||
global $g5;
|
||||
|
||||
$sql = "INSERT INTO {$g5['kakao5_preset_history_table']}
|
||||
(mb_id, kp_id, ph_rcvnm, ph_rcv, ph_template_code, ph_alt_send, ph_request_num, ph_send_datetime, ph_state)
|
||||
VALUES
|
||||
('" . sql_escape_string($mb_id) . "',
|
||||
'" . (int)$preset_id . "',
|
||||
'" . sql_escape_string($rcvnm) . "',
|
||||
'" . sql_escape_string($rcv) . "',
|
||||
'" . sql_escape_string($template_code) . "',
|
||||
'" . sql_escape_string($alt_send) . "',
|
||||
'" . sql_escape_string($request_num) . "',
|
||||
NOW(),
|
||||
0)";
|
||||
|
||||
$result = sql_query($sql);
|
||||
|
||||
if ($result) {
|
||||
return sql_insert_id();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 전송내역 업데이트
|
||||
*/
|
||||
function update_alimtalk_history($history_id, $update_data = [])
|
||||
{
|
||||
global $g5;
|
||||
|
||||
if (!$history_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$set_arr = [];
|
||||
|
||||
// update_data가 들어오면 해당 값들로 업데이트
|
||||
if (!empty($update_data) && is_array($update_data)) {
|
||||
foreach ($update_data as $key => $val) {
|
||||
$set_arr[] = sql_escape_string($key) . " = '" . sql_escape_string($val) . "'";
|
||||
}
|
||||
}
|
||||
|
||||
// 업데이트할 내용이 없음
|
||||
if (empty($set_arr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "UPDATE {$g5['kakao5_preset_history_table']}
|
||||
SET " . implode(', ', $set_arr) . "
|
||||
WHERE ph_id = '" . (int)$history_id . "'";
|
||||
|
||||
return sql_query($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 알림톡용 상품명 생성 (2개 이상일 경우 '외 N건' 추가)
|
||||
*/
|
||||
function get_alimtalk_cart_item_name($od_id)
|
||||
{
|
||||
global $g5;
|
||||
|
||||
$sql = "SELECT it_name FROM {$g5['g5_shop_cart_table']} WHERE od_id = '" . sql_escape_string($od_id) . "'";
|
||||
$res = sql_query($sql);
|
||||
|
||||
$names = array();
|
||||
while ($row = sql_fetch_array($res)) $names[] = $row['it_name'];
|
||||
if (!$names) return '';
|
||||
|
||||
return $names[0] . ($names[1] ? ' 외 ' . (count($names)-1) . '건' : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 정보로 알림톡 발송
|
||||
*
|
||||
* @param string $tpl 템플릿 코드 (예: AD-OR01)
|
||||
* @param string $type 관리자 유형 (super|group|board)
|
||||
* @param array $conditions 치환 변수 배열
|
||||
* @param array $otherTypes 발송 중복 확인용 관리자 유형 ['super', 'group', 'board']
|
||||
* @return array|false send_alimtalk_preset 반환값 또는 false
|
||||
*/
|
||||
function send_admin_alimtalk($tpl, $type = 'super', $conditions = [], $otherTypes = [])
|
||||
{
|
||||
$admin = get_admin($type);
|
||||
|
||||
// 연락처가 없으면 발송하지 않음
|
||||
if (empty($admin['mb_hp'])) return false;
|
||||
|
||||
// 다른 관리자 정보가 겹치는 게 있으면 발송 안함
|
||||
if(!empty($otherTypes)){
|
||||
foreach($otherTypes as $otherType){
|
||||
// 자기 자신은 비교하지 않음
|
||||
if ($otherType == $type) continue;
|
||||
|
||||
$other = get_admin($otherType, 'mb_id, mb_hp');
|
||||
if (empty($other)) continue;
|
||||
|
||||
// 다른 역할과 동일 인물(또는 동일 번호)이라면 발송하지 않음
|
||||
$sameId = !empty($admin['mb_id']) && !empty($other['mb_id']) && $admin['mb_id'] == $other['mb_id'];
|
||||
$sameHp = !empty($other['mb_hp']) && $admin['mb_hp'] == $other['mb_hp'];
|
||||
|
||||
if ($sameId || $sameHp) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return send_alimtalk_preset(
|
||||
$tpl,
|
||||
[
|
||||
'rcv' => $admin['mb_hp'],
|
||||
'rcvnm' => $admin['mb_name'] ?? ''
|
||||
],
|
||||
$conditions
|
||||
);
|
||||
}
|
||||
@ -1,238 +0,0 @@
|
||||
<?php
|
||||
include_once(G5_KAKAO5_PATH . '/Popbill/PopbillKakao.php');
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
** 공통 : 팝빌 카카오톡 발송
|
||||
**
|
||||
*************************************************************************/
|
||||
/**
|
||||
* kakao 서비스 인스턴스 생성
|
||||
*/
|
||||
function get_kakao_service_instance() {
|
||||
global $linkID, $secretKey;
|
||||
|
||||
// 이미 생성된 인스턴스가 있으면 반환
|
||||
static $KakaoService = null;
|
||||
if ($KakaoService !== null) {
|
||||
return $KakaoService;
|
||||
}
|
||||
|
||||
// 통신방식 기본은 CURL , curl 사용에 문제가 있을경우 STREAM 사용가능.
|
||||
define('LINKHUB_COMM_MODE','CURL');
|
||||
|
||||
$KakaoService = new KakaoService($linkID, $secretKey);
|
||||
|
||||
// 연동환경 설정, true-테스트, false-운영(Production), (기본값:false)
|
||||
$KakaoService->IsTest(G5_KAKAO5_IS_TEST);
|
||||
|
||||
return $KakaoService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 팝빌 정보 확인
|
||||
*/
|
||||
function get_popbill_service_info(){
|
||||
global $userID, $corpnum;
|
||||
|
||||
if (empty($userID) || strlen($userID) < 4) {
|
||||
return array('error' => '연결 실패: 회원아이디가 없거나 올바르지 않습니다. 회원아이디를 확인해주세요.');
|
||||
}
|
||||
|
||||
try {
|
||||
$KakaoService = get_kakao_service_instance();
|
||||
$corpInfo = $KakaoService->GetCorpInfo($corpnum, $userID);
|
||||
$balance = $KakaoService->GetBalance($corpnum);
|
||||
|
||||
if ($balance === false || $balance < 0) {
|
||||
return array('error' => '팝빌 API 연결에 실패했습니다. 설정값을 확인해주세요.');
|
||||
}
|
||||
|
||||
return array('success' => true, 'balance' => $balance, 'corpInfo' => $corpInfo);
|
||||
} catch (Exception $e) {
|
||||
return array('error' => '팝빌 서비스 처리 중 오류가 발생했습니다: ' . $e->getMessage(), 'code' => $e->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 팝빌 템플릿 목록 조회
|
||||
*/
|
||||
function get_popbill_template_list(){
|
||||
global $corpnum;
|
||||
|
||||
try {
|
||||
$KakaoService = get_kakao_service_instance();
|
||||
$templates = $KakaoService->ListATSTemplate($corpnum);
|
||||
|
||||
if (empty($templates)) {
|
||||
return array('error' => '템플릿 목록을 가져올 수 없습니다.');
|
||||
}
|
||||
|
||||
return $templates;
|
||||
} catch (Exception $e) {
|
||||
return array('error' => '팝빌 서비스 처리 중 오류가 발생했습니다: ' . $e->getMessage(), 'code' => $e->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 포인트 충전 팝업 URL
|
||||
*/
|
||||
function get_popbill_point_URL(){
|
||||
global $corpnum, $userID;
|
||||
|
||||
try {
|
||||
$KakaoService = get_kakao_service_instance();
|
||||
$url = $KakaoService->GetChargeURL($corpnum, $userID);
|
||||
|
||||
if (empty($url)) {
|
||||
return array('error' => '포인트 충전 URL을 가져올 수 없습니다.');
|
||||
}
|
||||
|
||||
return $url;
|
||||
} catch (Exception $e) {
|
||||
return array('error' => '팝빌 서비스 처리 중 오류가 발생했습니다: ' . $e->getMessage(), 'code' => $e->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 템플릿 정보 확인
|
||||
*/
|
||||
function get_popbill_template_info($template_code, $type = ''){
|
||||
global $corpnum;
|
||||
|
||||
try {
|
||||
$KakaoService = get_kakao_service_instance();
|
||||
$info = $KakaoService->GetATSTemplate($corpnum, $template_code);
|
||||
|
||||
if (empty($info)) {
|
||||
return array('error' => '해당 템플릿 정보를 가져올 수 없습니다.');
|
||||
}
|
||||
|
||||
if ($type) {
|
||||
if (is_object($info) && isset($info->$type)) {
|
||||
return $info->$type;
|
||||
} else if (is_array($info) && isset($info[$type])) {
|
||||
return $info[$type];
|
||||
} else {
|
||||
return array('error' => '요청하신 타입의 정보가 없습니다.');
|
||||
}
|
||||
}
|
||||
|
||||
return $info;
|
||||
} catch (Exception $e) {
|
||||
return array('error' => '팝빌 서비스 처리 중 오류가 발생했습니다: ' . $e->getMessage(), 'code' => $e->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 템플릿 관리 팝업 URL
|
||||
*/
|
||||
function get_popbill_template_manage_URL(){
|
||||
global $corpnum, $userID;
|
||||
|
||||
try {
|
||||
$KakaoService = get_kakao_service_instance();
|
||||
$url = $KakaoService->GetATSTemplateMgtURL($corpnum, $userID);
|
||||
|
||||
if (empty($url)) {
|
||||
return array('error' => '템플릿관리 URL을 가져올 수 없습니다.');
|
||||
}
|
||||
|
||||
return $url;
|
||||
} catch (Exception $e) {
|
||||
return array('error' => '팝빌 서비스 처리 중 오류가 발생했습니다: ' . $e->getMessage(), 'code' => $e->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 플러스친구 관리 팝업 URL
|
||||
*/
|
||||
function get_popbill_plusfriend_manage_URL(){
|
||||
global $corpnum, $userID;
|
||||
try {
|
||||
$KakaoService = get_kakao_service_instance();
|
||||
$url = $KakaoService->GetPlusFriendMgtURL($corpnum, $userID);
|
||||
if (empty($url)) {
|
||||
return array('error' => '플러스친구 관리 URL을 가져올 수 없습니다.');
|
||||
}
|
||||
return $url;
|
||||
} catch (Exception $e) {
|
||||
return array('error' => '팝빌 서비스 처리 중 오류가 발생했습니다: ' . $e->getMessage(), 'code' => $e->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 전송내역 관리 팝업 URL
|
||||
*/
|
||||
function get_popbill_send_manage_URL(){
|
||||
global $corpnum, $userID;
|
||||
try {
|
||||
$KakaoService = get_kakao_service_instance();
|
||||
$url = $KakaoService->GetSentListURL($corpnum, $userID);
|
||||
if (empty($url)) {
|
||||
return array('error' => '전송내역 URL을 가져올 수 없습니다.');
|
||||
}
|
||||
return $url;
|
||||
} catch (Exception $e) {
|
||||
return array('error' => '팝빌 서비스 처리 중 오류가 발생했습니다: ' . $e->getMessage(), 'code' => $e->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 발신번호 등록 팝업 URL
|
||||
*/
|
||||
function get_popbill_sender_number_URL(){
|
||||
global $corpnum, $userID;
|
||||
try {
|
||||
$KakaoService = get_kakao_service_instance();
|
||||
$url = $KakaoService->GetSenderNumberMgtURL($corpnum, $userID);
|
||||
if (empty($url)) {
|
||||
return array('error' => '발신번호 등록 URL을 가져올 수 없습니다.');
|
||||
}
|
||||
return $url;
|
||||
} catch (Exception $e) {
|
||||
return array('error' => '팝빌 서비스 처리 중 오류가 발생했습니다: ' . $e->getMessage(), 'code' => $e->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
** 알림톡 : 팝빌 카카오톡 발송
|
||||
**
|
||||
*************************************************************************/
|
||||
/**
|
||||
* 팝빌 알림톡 전송 함수 (SendATS 파라미터를 배열에서 바로 전달, 예외처리 포함)
|
||||
*/
|
||||
function send_popbill_alimtalk($params = []){
|
||||
global $corpnum, $userID;
|
||||
|
||||
try {
|
||||
$KakaoService = get_kakao_service_instance();
|
||||
|
||||
$receipt_num = $KakaoService->SendATS(
|
||||
$corpnum,
|
||||
$params['template_code'],
|
||||
$params['sender_hp'],
|
||||
$params['content'],
|
||||
isset($params['alt_content']) ? $params['alt_content'] : '',
|
||||
isset($params['alt_send']) ? $params['alt_send'] : null,
|
||||
$params['messages'],
|
||||
isset($params['reserveDT']) ? $params['reserveDT'] : null,
|
||||
$userID,
|
||||
isset($params['request_num']) ? $params['request_num'] : null,
|
||||
isset($params['buttons']) ? $params['buttons'] : null,
|
||||
isset($params['alt_subject']) ? $params['alt_subject'] : ''
|
||||
);
|
||||
|
||||
if ($receipt_num) {
|
||||
return $receipt_num;
|
||||
} else {
|
||||
return [ 'error' => '알림톡 전송에 실패했습니다.' ];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'error' => '팝빌 서비스 처리 중 오류가 발생했습니다: ' . $e->getMessage(),
|
||||
'code' => $e->getCode()
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -331,18 +331,6 @@ if($result) {
|
||||
}
|
||||
}
|
||||
|
||||
// 알림톡 발송 BEGIN: 회원가입 (CU-MB01/AD-MB01) -------------------------------------
|
||||
include_once(G5_KAKAO5_PATH.'/kakao5.lib.php');
|
||||
$conditions = ['mb_id' => $mb_id]; // 변수 치환 정보
|
||||
|
||||
$ad_atk = send_admin_alimtalk('AD-MB01', 'super', $conditions); // 관리자
|
||||
|
||||
// 회원 - 휴대폰 번호가 있을 경우만
|
||||
if (!empty($mb_hp)) {
|
||||
$cu_atk = send_alimtalk_preset('CU-MB01', ['rcv' => $mb_hp, 'rcvnm' => $mb_name], $conditions); // 회원
|
||||
}
|
||||
// 알림톡 발송 END --------------------------------------------------------
|
||||
|
||||
// 사용자 코드 실행
|
||||
@include_once ($member_skin_path.'/register_form_update.tail.skin.php');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user