mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-06 10:11:38 +09:00
Move all composer files inside the common directory
- 2022년 3월 개발팀 결정사항 적용 - 모듈 등 서드파티 자료 개발시 composer를 사용하면 상위 경로에 있는 코어의 composer.json을 수정하고, 코어의 vendor 디렉토리를 건드리는 것이 기본값임 - 이를 방지하기 위해 코어의 composer.json과 vendor를 common 디렉토리 안으로 이동하여, 모듈 경로에서 상위 폴더로 인식하지 않도록 함
This commit is contained in:
parent
7b912d21fc
commit
5fff6b6eab
1478 changed files with 2 additions and 2 deletions
174
common/vendor/coolsms/php-sdk/app/Nurigo/Api/GroupMessage.php
vendored
Normal file
174
common/vendor/coolsms/php-sdk/app/Nurigo/Api/GroupMessage.php
vendored
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
<?php
|
||||
/* vi:set sw=4 ts=4 expandtab: */
|
||||
|
||||
namespace Nurigo\Api;
|
||||
|
||||
use Nurigo\Coolsms;
|
||||
use Nurigo\Exceptions\CoolsmsSDKException;
|
||||
|
||||
require_once __DIR__ . "/../../../bootstrap.php";
|
||||
|
||||
/**
|
||||
* @class GroupMessage
|
||||
* @brief management group message, using Rest API
|
||||
*/
|
||||
class GroupMessage extends Coolsms
|
||||
{
|
||||
/**
|
||||
* @brief create create group ( HTTP Method GET )
|
||||
* @param object $options {
|
||||
* @param string charset [optional]
|
||||
* @param string srk [optional]
|
||||
* @param string mode [optional]
|
||||
* @param string delay [optional]
|
||||
* @param boolean force_sms [optional]
|
||||
* @param string os_platform [optional]
|
||||
* @param string dev_lang [optional]
|
||||
* @param string sdk_version [optional]
|
||||
* @param string app_version [optional] }
|
||||
* @return object(group_id)
|
||||
*/
|
||||
public function createGroup($options)
|
||||
{
|
||||
return $this->request('new_group', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get group list ( HTTP Method GET )
|
||||
* @param None
|
||||
* @return array['groupid', 'groupid'...]
|
||||
*/
|
||||
public function getGroupList()
|
||||
{
|
||||
return $this->request('group_list');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief delete groups ( HTTP Method POST )
|
||||
* @param string $group_ids [required]
|
||||
* @return object(count)
|
||||
*/
|
||||
public function deleteGroups($group_ids)
|
||||
{
|
||||
if (!$group_ids) throw new CoolsmsSDKException('group_ids is required', 202);
|
||||
|
||||
$options = new \stdClass();
|
||||
$options->group_ids = $group_ids;
|
||||
return $this->request('delete_groups', $options, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get group info ( HTTP Method GET )
|
||||
* @param string $group_id [required]
|
||||
* @return object(group_id, message_count)
|
||||
*/
|
||||
public function getGroupInfo($group_id)
|
||||
{
|
||||
if (!$group_id) throw new CoolsmsSDKException('group_id is required', 202);
|
||||
|
||||
$options = new \stdClass();
|
||||
$options->group_id = $group_id;
|
||||
return $this->request(sprintf('groups/%s', $group_id), $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief add messages to group ( HTTP Method POST )
|
||||
* @param object $options {
|
||||
* @param string group_id [required]
|
||||
* @param string to [required]
|
||||
* @param string from [required]
|
||||
* @param string text [required]
|
||||
* @param string image_id [optional]
|
||||
* @param string refname [optional]
|
||||
* @param string country [optional]
|
||||
* @param string datetime [optional]
|
||||
* @param string subject [optional]
|
||||
* @param integer delay [optional] }
|
||||
* @return object(success_count, error_count, error_list['index':'code', 'index', 'code'])
|
||||
*/
|
||||
public function addMessages($options)
|
||||
{
|
||||
if (!isset($options->group_id) || !isset($options->to) || !isset($options->text) || !isset($options->from)) {
|
||||
throw new CoolsmsSDKException('group_id, to, text, from is required', 202);
|
||||
}
|
||||
|
||||
return $this->request(sprintf('groups/%s/add_messages', $options->group_id), $options, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief add json type messages to group ( HTTP Method POST )
|
||||
* @param object $options {
|
||||
* @param string group_id [required]
|
||||
* @param string messages [required] [{
|
||||
* @param string to [required]
|
||||
* @param string from [required]
|
||||
* @param string text [required]
|
||||
* @param string image_id [optional]
|
||||
* @param string refname [optional]
|
||||
* @param string country [optional]
|
||||
* @param string datetime [optional]
|
||||
* @param string subject [optional]
|
||||
* @param integer delay [optional] }] }
|
||||
* @return array[object(success_count, error_count, error_list['index':'code', 'index', 'code']), ...]
|
||||
*/
|
||||
public function addMessagesJSON($options)
|
||||
{
|
||||
if (!isset($options->group_id) || !isset($options->messages)) throw new CoolsmsSDKException('group_id and messages is required', 202);
|
||||
foreach ($options->messages as $val) {
|
||||
if (!isset($val->to) || !isset($val->text) || !isset($val->from)) {
|
||||
throw new CoolsmsSDKException('to, text, from is required', 202);
|
||||
}
|
||||
}
|
||||
|
||||
$options->messages = json_encode($options->messages);
|
||||
return $this->request(sprintf('groups/%s/add_messages.json', $options->group_id), $options, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get message list ( HTTP Method GET )
|
||||
* @param string $group_id [required]
|
||||
* @param integer $offset [optional]
|
||||
* @param integer $limit [optional]
|
||||
* @return object(total_count, offset, limit, list['message_id', 'message_id' ...])
|
||||
*/
|
||||
public function getMessageList($group_id, $offset = 0, $limit = 20)
|
||||
{
|
||||
if (!$group_id) throw new CoolsmsSDKException('group_id is required', 202);
|
||||
|
||||
$options = new \stdClass();
|
||||
$options->group_id = $group_id;
|
||||
$options->offset = $offset;
|
||||
$options->limit = $limit;
|
||||
return $this->request(sprintf('groups/%s/message_list', $options->group_id), $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief delete message from group ( HTTP Method POST )
|
||||
* @param string $group_id [required]
|
||||
* @param string $message_ids [required]
|
||||
* @return object(success_count)
|
||||
*/
|
||||
public function deleteMessages($group_id, $message_ids)
|
||||
{
|
||||
if (!$group_id || !$message_ids) throw new CoolsmsSDKException('group_id and message_ids are required', 202);
|
||||
|
||||
$options = new \stdClass();
|
||||
$options->group_id = $group_id;
|
||||
$options->message_ids = $message_ids;
|
||||
return $this->request(sprintf('groups/%s/delete_messages', $options->group_id), $options, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief send group message ( HTTP Method POST )
|
||||
* @param string $group_id [required]
|
||||
* @return object(group_id)
|
||||
*/
|
||||
public function sendGroupMessage($group_id)
|
||||
{
|
||||
if (!$group_id) throw new CoolsmsSDKException('group_id is required', 202);
|
||||
|
||||
$options = new \stdClass();
|
||||
$options->group_id = $group_id;
|
||||
return $this->request(sprintf('groups/%s/send', $group_id), $options, true);
|
||||
}
|
||||
}
|
||||
74
common/vendor/coolsms/php-sdk/app/Nurigo/Api/Image.php
vendored
Normal file
74
common/vendor/coolsms/php-sdk/app/Nurigo/Api/Image.php
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
/* vi:set sw=4 ts=4 expandtab: */
|
||||
|
||||
namespace Nurigo\Api;
|
||||
|
||||
use Nurigo\Coolsms;
|
||||
use Nurigo\Exceptions\CoolsmsSDKException;
|
||||
|
||||
require_once __DIR__ . "/../../../bootstrap.php";
|
||||
|
||||
/**
|
||||
* @class Image
|
||||
* @brief management image, using Rest API
|
||||
*/
|
||||
class Image extends Coolsms
|
||||
{
|
||||
/**
|
||||
* @brief get image list( HTTP Method GET )
|
||||
* @param integer $offset [optional]
|
||||
* @param integer $limit [optional]
|
||||
* @return object(total_count, offset, limit, list['image_id', 'image_id' ...])
|
||||
*/
|
||||
public function getImageList($offset = null, $limit = null)
|
||||
{
|
||||
$options = new \stdClass();
|
||||
$options->offset = $offset;
|
||||
$options->limit = $limit;
|
||||
return $this->request('image_list', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get image info ( HTTP Method GET )
|
||||
* @param string $image_id [required]
|
||||
* @return object(image_id, file_name, original_name, file_size, width, height)
|
||||
*/
|
||||
public function getImageInfo($image_id)
|
||||
{
|
||||
if (!$image_id) throw new CoolsmsSDKException('image_id is required', 202);
|
||||
|
||||
$options = new \stdClass();
|
||||
$options->image_id = $image_id;
|
||||
return $this->request(sprintf('images/%s', $image_id), $options);;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief upload image ( HTTP Method POST )
|
||||
* @param mixed $image [required]
|
||||
* @param string $encoding [optional]
|
||||
* @return object(image_id)
|
||||
*/
|
||||
public function uploadImage($image, $encoding = null)
|
||||
{
|
||||
if (!$image) throw new CoolsmsSDKException('image is required', 202);
|
||||
|
||||
$options = new \stdClass();
|
||||
$options->image = $image;
|
||||
$options->encoding = $encoding;
|
||||
return $this->request('upload_image', $options, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief delete images ( HTTP Method POST )
|
||||
* @param string $image_ids [required]
|
||||
* @return object(success_count)
|
||||
*/
|
||||
public function deleteImages($image_ids)
|
||||
{
|
||||
if (!$image_ids) throw new CoolsmsSDKException('image_ids is required', 202);
|
||||
|
||||
$options = new \stdClass();
|
||||
$options->image_ids = $image_ids;
|
||||
return $this->request('delete_images', $options, true);
|
||||
}
|
||||
}
|
||||
108
common/vendor/coolsms/php-sdk/app/Nurigo/Api/Message.php
vendored
Normal file
108
common/vendor/coolsms/php-sdk/app/Nurigo/Api/Message.php
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
/* vi:set sw=4 ts=4 expandtab: */
|
||||
|
||||
namespace Nurigo\Api;
|
||||
|
||||
use Nurigo\Coolsms;
|
||||
use Nurigo\Exceptions\CoolsmsSDKException;
|
||||
|
||||
require_once __DIR__ . "/../../../bootstrap.php";
|
||||
|
||||
/**
|
||||
* @class Message
|
||||
* @brief management message, using Rest API
|
||||
*/
|
||||
class Message extends Coolsms
|
||||
{
|
||||
/**
|
||||
* @brief send message ( HTTP Method POST )
|
||||
* @param object $options {
|
||||
* @param string to [required]
|
||||
* @param string from [required]
|
||||
* @param string text [required]
|
||||
* @param string type [optional]
|
||||
* @param mixed image [optional]
|
||||
* @param string image_encoding [optional]
|
||||
* @param string refname [optional]
|
||||
* @param mixed country [optional]
|
||||
* @param string datetime [optional]
|
||||
* @param string subject [optional]
|
||||
* @param string charset [optional]
|
||||
* @param string srk [optional]
|
||||
* @param string mode [optional]
|
||||
* @param string extension [optional]
|
||||
* @param integer delay [optional]
|
||||
* @param boolean force_sms [optional]
|
||||
* @param string app_version [optional] }
|
||||
* @return object(recipient_number, group_id, message_id, result_code, result_message)
|
||||
*/
|
||||
public function send($options)
|
||||
{
|
||||
// check require fields. ( 'to, from, 'text' )
|
||||
if (!isset($options->to) || !isset($options->from) || !isset($options->text)) throw new CoolsmsSDKException('"to, from, text" must be entered', 202);
|
||||
|
||||
return $this->request('send', $options, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief sent message list ( HTTP Method GET )
|
||||
* @param object $options {
|
||||
* @param integer offset [optional]
|
||||
* @param integer limit [optional]
|
||||
* @param string rcpt [optional]
|
||||
* @param string start [optional]
|
||||
* @param string end [optional]
|
||||
* @param string status [optional]
|
||||
* @param string status [optional]
|
||||
* @param string resultcode [optional]
|
||||
* @param string notin_resultcode [optional]
|
||||
* @param string message_id [optional]
|
||||
* @param string group_id [optional] }
|
||||
* @return object(total count, list_count, page, data['type', 'accepted_time', 'recipient_number', 'group_id', 'message_id', 'status', 'result_code', 'result_message', 'sent_time', 'text'])
|
||||
*/
|
||||
public function sent($options = null)
|
||||
{
|
||||
return $this->request('sent', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief cancel reserve message. mid or gid either one must be entered. ( HTTP Method POST )
|
||||
* @param string $mid [optional]
|
||||
* @param string $gid [optional]
|
||||
* @return None
|
||||
*/
|
||||
public function cancel($mid = null, $gid = null)
|
||||
{
|
||||
// mid or gid is empty. throw exception
|
||||
if (!$mid && !$gid) throw new CoolsmsSDKException('mid or gid either one must be entered', 202);
|
||||
|
||||
$options = new \stdClass();
|
||||
if ($mid) $options->mid = $mid;
|
||||
if ($gid) $options->gid = $gid;
|
||||
return $this->request('cancel', $options, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get remaining balance ( HTTP Method GET )
|
||||
* @param None
|
||||
* @return object(cash, point)
|
||||
*/
|
||||
public function getBalance()
|
||||
{
|
||||
return $this->request('balance');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get status ( HTTP Method GET )
|
||||
* @param object $options {
|
||||
* @param integer count [optional]
|
||||
* @param string unit [optional]
|
||||
* @param string date [optional]
|
||||
* @param integer channel [optional] }
|
||||
* @return object(registdate, sms_average, sms_sk_average, sms_kt_average, sms_lg_average, mms_average, mms_sk_average, mms_kt_average, mms_lg_average)
|
||||
*/
|
||||
public function getStatus($options = null)
|
||||
{
|
||||
return $this->request('status', $options);
|
||||
}
|
||||
}
|
||||
116
common/vendor/coolsms/php-sdk/app/Nurigo/Api/SenderID.php
vendored
Normal file
116
common/vendor/coolsms/php-sdk/app/Nurigo/Api/SenderID.php
vendored
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
/* vi:set sw=4 ts=4 expandtab: */
|
||||
|
||||
namespace Nurigo\Api;
|
||||
|
||||
use Nurigo\Coolsms;
|
||||
use Nurigo\Exceptions\CoolsmsSDKException;
|
||||
|
||||
require_once __DIR__ . "/../../../bootstrap.php";
|
||||
|
||||
/**
|
||||
* @class SenderID
|
||||
* @brief management sender id, using Rest API
|
||||
*/
|
||||
class SenderID extends Coolsms
|
||||
{
|
||||
/**
|
||||
* @brief change api name and api version
|
||||
* @param string $api_key [required]
|
||||
* @param string $api_secret [required]
|
||||
* @param boolean $basecamp [optional]
|
||||
* @return object(group_id)
|
||||
*/
|
||||
function __construct($api_key, $api_secret, $basecamp = false)
|
||||
{
|
||||
// set api_key and api_secret
|
||||
parent::__construct($api_key, $api_secret, $basecamp);
|
||||
|
||||
// set API and version
|
||||
$this->setApiConfig("senderid", "1.1");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief sender id registration request ( HTTP Method POST )
|
||||
* @param string $phone [required]
|
||||
* @param string $site_user [optional]
|
||||
* @return object(handle_key, ars_number)
|
||||
*/
|
||||
public function register($phone, $site_user = null)
|
||||
{
|
||||
if (!$phone) throw new CoolsmsSDKException('phone number is required', 202);
|
||||
|
||||
$options = new \stdClass();
|
||||
$options->phone = $phone;
|
||||
$options->site_user = $site_user;
|
||||
return $this->request('register', $options, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief verify sender id ( HTTP Method POST )
|
||||
* @param string $handle_key [required]
|
||||
* @return none
|
||||
*/
|
||||
public function verify($handle_key)
|
||||
{
|
||||
if (!$handle_key) throw new CoolsmsSDKException('handle_key is required', 202);
|
||||
|
||||
$options = new \stdClass();
|
||||
$options->handle_key = $handle_key;
|
||||
return $this->request('verify', $options, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief delete sender id ( HTTP Method POST )
|
||||
* @param string $handle_key [required]
|
||||
* @return none
|
||||
*/
|
||||
public function delete($handle_key)
|
||||
{
|
||||
if (!$handle_key) throw new CoolsmsSDKException('handle_key is required', 202);
|
||||
|
||||
$options = new \stdClass();
|
||||
$options->handle_key = $handle_key;
|
||||
return $this->request('delete', $options, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get sender id list ( HTTP Method GET )
|
||||
* @param string $site_user [optional]
|
||||
* @return object(site_user, idno, phone_number, flag_default, updatetime, regdate)
|
||||
*/
|
||||
public function getSenderidList($site_user = null)
|
||||
{
|
||||
$options = new \stdClass();
|
||||
$options->site_user = $site_user;
|
||||
return $this->request('list', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief set default sender id ( HTTP Method POST )
|
||||
* @param string $handle_key [required]
|
||||
* @param string $site_user [optional]
|
||||
* @return none
|
||||
*/
|
||||
public function setDefault($handle_key, $site_user = null)
|
||||
{
|
||||
if (!$handle_key) throw new CoolsmsSDKException('handle_key is required', 202);
|
||||
|
||||
$options = new \stdClass();
|
||||
$options->handle_key = $handle_key;
|
||||
$options->site_user = $site_user;
|
||||
return $this->request('set_default', $options, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get default sender id ( HTTP Method GET )
|
||||
* @param string $site_user [optional]
|
||||
* @return object(handle_key, phone_number)
|
||||
*/
|
||||
public function getDefault($site_user = null)
|
||||
{
|
||||
$options = new \stdClass();
|
||||
$options->site_user = $site_user;
|
||||
return $this->request('get_default', $options);
|
||||
}
|
||||
}
|
||||
295
common/vendor/coolsms/php-sdk/app/Nurigo/Coolsms.php
vendored
Normal file
295
common/vendor/coolsms/php-sdk/app/Nurigo/Coolsms.php
vendored
Normal file
|
|
@ -0,0 +1,295 @@
|
|||
<?php
|
||||
/* vi:set sw=4 ts=4 expandtab: */
|
||||
|
||||
/**
|
||||
* Copyright (C) 2008-2016 NURIGO \n
|
||||
* http://www.coolsms.co.kr
|
||||
*/
|
||||
|
||||
/**
|
||||
* @mainpage PHP SDK
|
||||
* @section intro 소개
|
||||
* - 소개 : Coolsms REST API
|
||||
* - 버전 : 2.0
|
||||
* - 설명 : Coolsms REST API 를 이용 보다 빠르고 안전하게 문자메시지를 보낼 수 있는 PHP로 만들어진 SDK 입니다.
|
||||
* @section CreateInfo 작성 정보
|
||||
* - 작성자 : Nurigo
|
||||
* - 작성일 : 2016/05/13
|
||||
* @section Caution 주의할 사항
|
||||
* - PHP SDK 2.0 은 PSR4에 근거하여 만들어 졌습니다. autoloading 과 namingspace의 개념을 알고 사용 하시는게 더 좋습니다.
|
||||
* @section common 기타 정보
|
||||
* - 저작권 GPL v2
|
||||
*/
|
||||
|
||||
namespace Nurigo;
|
||||
|
||||
use Nurigo\Exceptions\CoolsmsServerException;
|
||||
use Nurigo\Exceptions\CoolsmsSystemException;
|
||||
use Nurigo\Exceptions\CoolsmsSDKException;
|
||||
|
||||
require_once __DIR__ . "/../../bootstrap.php";
|
||||
|
||||
// check php extension "curl_init, json_decode"
|
||||
if (!function_exists('curl_init')) {
|
||||
throw new CoolsmsSystemException('Coolsms needs the CURL PHP extension.', 301);
|
||||
}
|
||||
if (!function_exists('json_decode')) {
|
||||
throw new CoolsmsSystemException('Coolsms needs the JSON PHP extension.', 301);
|
||||
}
|
||||
|
||||
/**
|
||||
* @class Coolsms
|
||||
* @brief Coolsms Rest API core class, using the Rest API
|
||||
*/
|
||||
class Coolsms
|
||||
{
|
||||
const HOST = "https://api.coolsms.co.kr";
|
||||
const SDK_VERSION = "2.0";
|
||||
|
||||
private $api_name = "sms";
|
||||
private $api_version = "2";
|
||||
private $api_key;
|
||||
private $api_secret;
|
||||
private $resource;
|
||||
private $is_post;
|
||||
private $result;
|
||||
private $basecamp;
|
||||
private $user_agent;
|
||||
private $content;
|
||||
|
||||
/**
|
||||
* @brief Construct
|
||||
*/
|
||||
public function __construct($api_key, $api_secret, $basecamp = false)
|
||||
{
|
||||
$this->api_key = $api_key;
|
||||
$this->api_secret = $api_secret;
|
||||
if (isset($_SERVER['HTTP_USER_AGENT'])) $this->user_agent = $_SERVER['HTTP_USER_AGENT'];
|
||||
if ($basecamp) $this->basecamp = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Process curl
|
||||
*/
|
||||
public function curlProcess()
|
||||
{
|
||||
$ch = curl_init();
|
||||
if (!$ch) throw new CoolsmsSystemException(curl_error($ch), 399);
|
||||
// Set url. is_post true = POST , false = GET
|
||||
if ($this->is_post) {
|
||||
$url = sprintf("%s/%s/%s/%s", self::HOST, $this->api_name, $this->api_version, $this->resource);
|
||||
} else {
|
||||
$url = sprintf("%s/%s/%s/%s?%s", self::HOST, $this->api_name, $this->api_version, $this->resource, $this->content);
|
||||
}
|
||||
|
||||
// Set curl info
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // check SSL certificate
|
||||
//curl_setopt($ch, CURLOPT_SSLVERSION, 3); // SSL protocol version (need for https connect, 3 -> SSLv3)
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0); // include the header in the output (1 = true, 0 = false)
|
||||
curl_setopt($ch, CURLOPT_POST, $this->is_post); // POST GET method
|
||||
|
||||
// set POST data
|
||||
if ($this->is_post) {
|
||||
$header = array("Content-Type:multipart/form-data");
|
||||
|
||||
// route가 있으면 header에 붙여준다. substr 해준 이유는 앞에 @^가 붙기 때문에 자르기 위해서.
|
||||
if (isset($this->content['route'])) $header[] = "User-Agent:" . substr($this->content['route'], 1);
|
||||
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:multipart/form-data"));
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->content);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10); // TimeOut value
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // curl_exec() result output (1 = true, 0 = false)
|
||||
|
||||
$this->result = json_decode(curl_exec($ch));
|
||||
|
||||
// unless http status code is 200. throw exception.
|
||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($http_code != 200) throw new CoolsmsServerException($this->result, $http_code);
|
||||
|
||||
// check curl errors
|
||||
if (curl_errno($ch)) throw new CoolsmsSystemException(curl_error($ch), 399);
|
||||
|
||||
curl_close($ch);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief set http body content
|
||||
*/
|
||||
private function setContent($options)
|
||||
{
|
||||
// POST method content
|
||||
if ($this->is_post) {
|
||||
$this->content = array();
|
||||
foreach ($options as $key => $val) {
|
||||
if ($key != "text") $val = trim($val);
|
||||
|
||||
if ($key == "image") {
|
||||
$this->content[$key] = curl_file_create(realpath($val));
|
||||
} else {
|
||||
$this->content[$key] = sprintf("%s", $val);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// GET method content
|
||||
foreach ($options as $key => $val) {
|
||||
if ($key != "text") $val = trim($val);
|
||||
$this->content .= $key . "=" . urlencode($val) . "&";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @biref Make a signature with hash_hamac then return the signature
|
||||
*/
|
||||
private function getSignature($timestamp, $salt)
|
||||
{
|
||||
return hash_hmac('md5', $timestamp . $salt, $this->api_secret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set authenticate information
|
||||
*/
|
||||
protected function addInfos($options = null)
|
||||
{
|
||||
if (!isset($options)) $options = new \stdClass();
|
||||
if (!isset($options->User_Agent)) $options->User_Agent = sprintf("PHP REST API %s", $this->api_version);
|
||||
if (!isset($options->os_platform)) $options->os_platform = $this->getOS();
|
||||
if (!isset($options->dev_lang)) $options->dev_lang = sprintf("PHP %s", phpversion());
|
||||
if (!isset($options->sdk_version)) $options->sdk_version = sprintf("PHP SDK %s", self::SDK_VERSION);
|
||||
|
||||
// set salt & timestamp
|
||||
$options->salt = uniqid();
|
||||
$options->timestamp = (string)time();
|
||||
|
||||
// If basecamp is true '$coolsms_user' use
|
||||
isset($this->basecamp) ? $options->coolsms_user = $this->api_key : $options->api_key = $this->api_key;
|
||||
|
||||
$options->signature = $this->getSignature($options->timestamp, $options->salt);
|
||||
$this->setContent($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief set api resource and http method type
|
||||
* @param string $resource [required] related information. http://www.coolsms.co.kr/REST_API
|
||||
* @param boolean $is_post [optional] GET = false, POST = true
|
||||
*/
|
||||
protected function setResource($resource, $is_post = false)
|
||||
{
|
||||
$this->resource = $resource;
|
||||
$this->is_post = $is_post;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief https request using rest api
|
||||
* @param string $resource [required]
|
||||
* @param object $options [optional]
|
||||
* @param boolean $is_post [optional] GET = false, POST = true
|
||||
* @return mixed
|
||||
*/
|
||||
protected function request($resource, $options = null, $is_post = false)
|
||||
{
|
||||
if (!$resource) throw new CoolsmsSDKException('resource is required', 201);
|
||||
|
||||
// set http method and rest api path
|
||||
$this->setResource($resource, $is_post);
|
||||
|
||||
// set contents
|
||||
$this->addInfos($options);
|
||||
|
||||
// https request
|
||||
$this->curlProcess();
|
||||
|
||||
// return result
|
||||
return $this->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return result
|
||||
*/
|
||||
public function getResult()
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief set api name and api version
|
||||
* @param string $api_name [required] 'sms', 'senderid', 'image'
|
||||
* @param integer $api_version [required]
|
||||
*/
|
||||
public function setApiConfig($api_name, $api_version)
|
||||
{
|
||||
if (!isset($api_name) || !isset($api_version)) throw new CoolsmsSDKException('API name and version is requried', 201);
|
||||
$this->api_name = $api_name;
|
||||
$this->api_version = $api_version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return user's current OS
|
||||
*/
|
||||
function getOS()
|
||||
{
|
||||
$user_agent = $this->user_agent;
|
||||
$os_platform = "Unknown OS Platform";
|
||||
$os_array = array(
|
||||
'/windows nt 10/i' => 'Windows 10',
|
||||
'/windows nt 6.3/i' => 'Windows 8.1',
|
||||
'/windows nt 6.2/i' => 'Windows 8',
|
||||
'/windows nt 6.1/i' => 'Windows 7',
|
||||
'/windows nt 6.0/i' => 'Windows Vista',
|
||||
'/windows nt 5.2/i' => 'Windows Server 2003/XP x64',
|
||||
'/windows nt 5.1/i' => 'Windows XP',
|
||||
'/windows xp/i' => 'Windows XP',
|
||||
'/windows nt 5.0/i' => 'Windows 2000',
|
||||
'/windows me/i' => 'Windows ME',
|
||||
'/win98/i' => 'Windows 98',
|
||||
'/win95/i' => 'Windows 95',
|
||||
'/win16/i' => 'Windows 3.11',
|
||||
'/macintosh|mac os x/i' => 'Mac OS X',
|
||||
'/mac_powerpc/i' => 'Mac OS 9',
|
||||
'/linux/i' => 'Linux',
|
||||
'/ubuntu/i' => 'Ubuntu',
|
||||
'/iphone/i' => 'iPhone',
|
||||
'/ipod/i' => 'iPod',
|
||||
'/ipad/i' => 'iPad',
|
||||
'/android/i' => 'Android',
|
||||
'/blackberry/i' => 'BlackBerry',
|
||||
'/webos/i' => 'Mobile'
|
||||
);
|
||||
|
||||
foreach ($os_array as $regex => $value) {
|
||||
if (preg_match($regex, $user_agent)) {
|
||||
$os_platform = $value;
|
||||
}
|
||||
}
|
||||
return $os_platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return user's current browser
|
||||
*/
|
||||
function getBrowser()
|
||||
{
|
||||
$user_agent = $this->user_agent;
|
||||
$browser = "Unknown Browser";
|
||||
$browser_array = array(
|
||||
'/msie/i' => 'Internet Explorer',
|
||||
'/firefox/i' => 'Firefox',
|
||||
'/safari/i' => 'Safari',
|
||||
'/chrome/i' => 'Chrome',
|
||||
'/opera/i' => 'Opera',
|
||||
'/netscape/i' => 'Netscape',
|
||||
'/maxthon/i' => 'Maxthon',
|
||||
'/konqueror/i' => 'Konqueror',
|
||||
'/mobile/i' => 'Handheld Browser'
|
||||
);
|
||||
foreach ($browser_array as $regex => $value) {
|
||||
if (preg_match($regex, $user_agent)) {
|
||||
$browser = $value;
|
||||
}
|
||||
}
|
||||
return $browser;
|
||||
}
|
||||
}
|
||||
13
common/vendor/coolsms/php-sdk/app/Nurigo/Exceptions/CoolsmsException.php
vendored
Normal file
13
common/vendor/coolsms/php-sdk/app/Nurigo/Exceptions/CoolsmsException.php
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
/* vi:set sw=4 ts=4 expandtab: */
|
||||
|
||||
namespace Nurigo\Exceptions;
|
||||
|
||||
/**
|
||||
* @class CoolsmsException
|
||||
* @brief Thrown when an SDK call returns an comprehensive exception.
|
||||
*/
|
||||
class CoolsmsException extends \Exception
|
||||
{
|
||||
|
||||
}
|
||||
12
common/vendor/coolsms/php-sdk/app/Nurigo/Exceptions/CoolsmsSDKException.php
vendored
Normal file
12
common/vendor/coolsms/php-sdk/app/Nurigo/Exceptions/CoolsmsSDKException.php
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/* vi:set sw=4 ts=4 expandtab: */
|
||||
|
||||
namespace Nurigo\Exceptions;
|
||||
|
||||
/**
|
||||
* @class CoolsmsSDKException
|
||||
* @brief Thrown when an SDK call returns an exception.
|
||||
*/
|
||||
class CoolsmsSDKException extends CoolsmsException
|
||||
{
|
||||
}
|
||||
35
common/vendor/coolsms/php-sdk/app/Nurigo/Exceptions/CoolsmsServerException.php
vendored
Normal file
35
common/vendor/coolsms/php-sdk/app/Nurigo/Exceptions/CoolsmsServerException.php
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
/* vi:set sw=4 ts=4 expandtab: */
|
||||
|
||||
namespace Nurigo\Exceptions;
|
||||
|
||||
/**
|
||||
* @class CoolsmsServerException
|
||||
* @brief Thrown when an Server call returns an exception.
|
||||
*/
|
||||
class CoolsmsServerException extends CoolsmsException
|
||||
{
|
||||
/**
|
||||
* Coolsms API Response data
|
||||
*/
|
||||
protected $response;
|
||||
protected $response_data;
|
||||
|
||||
/**
|
||||
* @brief Make a new SDK Exception with the given result.
|
||||
* @param string $response [required] response from the API server & SDK Client
|
||||
* @param integer $code [required] response code
|
||||
*/
|
||||
public function __construct($response, $code) {
|
||||
$this->response = $response;
|
||||
$response_data = $response;
|
||||
parent::__construct(json_encode($response), $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief return json decoded response data
|
||||
*/
|
||||
public function getResponseData() {
|
||||
return $this->response_data;
|
||||
}
|
||||
}
|
||||
12
common/vendor/coolsms/php-sdk/app/Nurigo/Exceptions/CoolsmsSystemException.php
vendored
Normal file
12
common/vendor/coolsms/php-sdk/app/Nurigo/Exceptions/CoolsmsSystemException.php
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/* vi:set sw=4 ts=4 expandtab: */
|
||||
|
||||
namespace Nurigo\Exceptions;
|
||||
|
||||
/**
|
||||
* @class CoolsmsSystemException
|
||||
* @brief Thrown when an System call returns an exception.
|
||||
*/
|
||||
class CoolsmsSystemException extends CoolsmsException
|
||||
{
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue