Move all composer files inside the common directory

- 2022년 3월 개발팀 결정사항 적용
- 모듈 등 서드파티 자료 개발시 composer를 사용하면 상위 경로에 있는 코어의
  composer.json을 수정하고, 코어의 vendor 디렉토리를 건드리는 것이 기본값임
- 이를 방지하기 위해 코어의 composer.json과 vendor를 common 디렉토리 안으로
  이동하여, 모듈 경로에서 상위 폴더로 인식하지 않도록 함
This commit is contained in:
Kijin Sung 2022-12-26 16:33:32 +09:00
parent 7b912d21fc
commit 5fff6b6eab
1478 changed files with 2 additions and 2 deletions

View file

@ -0,0 +1 @@
/vendor/

26
common/vendor/coolsms/php-sdk/README.md vendored Normal file
View file

@ -0,0 +1,26 @@
# Coolsms PHP SDK
Send Message & Alimtalk using PHP and REST API.
## Installation
- The recommended way to install Coolsms PHP SDK is through composer:
```bash
$ composer require coolsms/php-sdk
```
- Package install url ( source code & examples ) : http://www.coolsms.co.kr/download/3130218
- Github : https://github.com/coolsms/php-sdk
## Requirements
* PHP 5.5 or greater
* Composer
* PHP CURL extension
* PHP JSON extension
## Usage
Look at the 'http://www.coolsms.co.kr/PHP_SDK_Example'.

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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;
}
}

View 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
{
}

View 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
{
}

View 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;
}
}

View 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
{
}

View file

@ -0,0 +1,2 @@
<?php
require_once __DIR__ . "/../../../vendor/autoload.php";

View file

@ -0,0 +1,24 @@
{
"name": "coolsms/php-sdk",
"description": "Send message using PHP and RestAPI[TEST]",
"type": "library",
"keywords": ["coolsms", "nurigo", "sms", "message", "messages", "cool", "textmessage", "mobile", "cellphone", "phone", "mms", "lms", "global"],
"license": "MIT",
"homepage": "http://coolsms.co.kr",
"authors": [
{
"name": "nurigo",
"email": "contact@nurigo.net",
"homepage": "http://coolsms.co.kr",
"role": "Developer"
}
],
"require": {
"php": ">=5.5.0"
},
"autoload": {
"psr-4": {
"Nurigo\\": "app/Nurigo"
}
}
}

20
common/vendor/coolsms/php-sdk/composer.lock generated vendored Normal file
View file

@ -0,0 +1,20 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "ec683450e574219efd4acfafbd3b213b",
"content-hash": "4caf4ba39832cc096d7930eaf24ad348",
"packages": [],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=5.5.0"
},
"platform-dev": []
}

View file

@ -0,0 +1,46 @@
<?php
/**
* #example_add_messages
*
* This sample code demonstrate how to add messages into group through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\GroupMessage;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new GroupMessage($api_key, $api_secret);
// options(to, from, text) are mandatory. must be filled
$options = new stdClass();
$options->to = '01000000000'; // 수신번호
$options->from = '01000000000'; // 발신번호
$options->text = '안녕하세요. 10000건을 20초안에 발송하는 빠르고 저렴한 CoolSMS의 테스팅 문자입니다. '; // 문자내용
$options->group_id = 'GID56CC00E21C4DC'; // group id
// Optional parameters for your own needs
// $options->type = 'SMS'; // Message type ( SMS, LMS, MMS, ATA )
// $options->image_id = 'IM289E9CISNWIC' // image_id. type must be set as 'MMS'
// $options->refname = ''; // Reference name
// $options->country = 82; // Korea(82) Japan(81) America(1) China(86) Default is Korea
// $options->datetime = '20140106153000'; // Format must be(YYYYMMDDHHMISS) 2014 01 06 15 30 00 (2014 Jan 06th 3pm 30 00)
// $options->subject = 'Hello World'; // set msg title for LMS and MMS
// $options->delay = 10; // '0~20' delay messages
// $options->sender_key = '55540253a3e61072...'; // 알림톡 사용을 위해 필요합니다. 신청방법 : http://www.coolsms.co.kr/AboutAlimTalk
// $options->template_code = 'C004'; // 알림톡 template code 입니다. 자세한 설명은 http://www.coolsms.co.kr/AboutAlimTalk을 참조해주세요.
$result = $rest->addMessages($options);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,58 @@
<?php
/**
* #example_add_messages
*
* This sample code demonstrate how to add json type messages into group through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\GroupMessage;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new GroupMessage($api_key, $api_secret);
// options(message, group_id) are mandatory. must be filled
$options = new stdClass();
$text = array(
0 => "안녕하세요.",
1 => "10000건을 20초안에 발송하는 빠르고 저렴한",
2 => "CoolSMS의 테스팅 문자입니다.");
$messages = array();
foreach($text as $val) {
$message = new stdClass();
$message->type = "SMS";
$message->to = "01000000000";
$message->from = "01000000000";
$message->text = $val;
$messages[] = $message;
// Optional parameters for your own needs
// $message->type = 'SMS'; // Message type ( SMS, LMS, MMS, ATA )
// $message->image_id = 'IM289E9CISNWIC' // image_id. type must be set as 'MMS'
// $message->refname = ''; // Reference name
// $message->country = 82; // Korea(82) Japan(81) America(1) China(86) Default is Korea
// $message->datetime = '20140106153000'; // Format must be(YYYYMMDDHHMISS) 2014 01 06 15 30 00 (2014 Jan 06th 3pm 30 00)
// $message->subject = 'Hello World'; // set msg title for LMS and MMS
// $message->delay = 10; // '0~20' delay messages
// $message->sender_key = '55540253a3e61072...'; // 알림톡 사용을 위해 필요합니다. 신청방법 : http://www.coolsms.co.kr/AboutAlimTalk
// $message->template_code = 'C004'; // 알림톡 template code 입니다. 자세한 설명은 http://www.coolsms.co.kr/AboutAlimTalk을 참조해주세요.
}
$options->messages = $messages;
$options->group_id = 'GID57317013931B0'; // group id
$result = $rest->addMessagesJSON($options);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,37 @@
<?php
/**
* #example_new_group
*
* This sample code demonstrate how to create sms group through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\GroupMessage;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new GroupMessage($api_key, $api_secret);
// Optional parameters for your own needs
$options = new stdClass();
// $options->charset = 'utf8'; // utf8, euckr default value is utf8
// $options->srk = ''; // Solution key
// $options->mode = 'test'; // If 'test' value. refund cash to point
// $options->delay = 10; // '0~20' delay messages
// $options->force_sms = true; // 'true or false' always send sms
// $options->app_version = ''; // App version
$result = $rest->createGroup($options);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,31 @@
<?php
/**
* #example_delete_group
*
* This sample code demonstrate how to delete sms group through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\GroupMessage;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new GroupMessage($api_key, $api_secret);
// group_ids are mandatory. must be filled
$group_ids = 'GID56CC00E21C4DC'; // ex) '1GCOLS23BDG','RGGBB11545'
$result = $rest->deleteGroups($group_ids);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,32 @@
<?php
/**
* #example_delete_messages
*
* This sample code demonstrate how to delete messages through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\GroupMessage;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new GroupMessage($api_key, $api_secret);
// group_id, message_ids are mandatory. must be filled
$group_id = 'GID56CC00E21C4DC'; // group id
$message_ids = '2838DFJFE02EI10TM'; // message ids. ex) '2838DFJFE02EI10TM','RGGBB11545'
$result = $rest->deleteMessages($group_id, $message_ids);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,31 @@
<?php
/**
* #example_group_info
*
* This sample code demonstrate how to check group info through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\GroupMessage;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new GroupMessage($api_key, $api_secret);
// group_id are mandatory. must be filled
$group_id = 'GIDFIWKEO19DIW29'; // group id
$result = $rest->getGroupInfo($group_id);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,28 @@
<?php
/**
* #example_group_list
*
* This sample code demonstrate how to check group list through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\GroupMessage;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new GroupMessage($api_key, $api_secret);
$result = $rest->getGroupList();
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,33 @@
<?php
/**
* #example_message_list
*
* This sample code demonstrate check message list through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\GroupMessage;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new GroupMessage($api_key, $api_secret);
// Optional parameters for your own needs
$group_id = 'GID57317013931B0'; // group id
$offset = 0; // default 0
$limit = 20; // default 20
$result = $rest->getMessageList($group_id, $offset, $limit);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,31 @@
<?php
/**
* #example_send
*
* This sample code demonstrate how to send group sms through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\GroupMessage;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new GroupMessage($api_key, $api_secret);
// group_id are mandatory. must be filled
$group_id = 'GID56CC00E21C4DC'; // group id. ex) '1GCOLS23BDG'
$result = $rest->sendGroupMessage($group_id);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,44 @@
<?php
/**
* #example_send_process
*
* This sample code demonstrate how to send group message through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\GroupMessage;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
$options = new stdClass();
// initiate rest api sdk object
$rest = new GroupMessage($api_key, $api_secret);
// create group
$result = $rest->createGroup($options);
$group_id = $result->group_id;
print_r($result);
// add messages
$options->to = '01000000000';
$options->from = '01000000000';
$options->text = '안녕하세요. 10000건을 20초안에 발송하는 빠르고 저렴한 CoolSMS의 테스팅 문자입니다. ';
$options->group_id = $group_id; // group id
$result = $rest->addMessages($options);
print_r($result);
// send messages
$result = $rest->sendGroupMessage($group_id);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,32 @@
<?php
/**
* #example_cancel
*
* This sample code demonstrate how to cancel reserved sms through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\Message;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new Message($api_key, $api_secret);
// Either mid or gid must be entered.
$options = new stdClass();
$mid = 'M52CB443257C61'; // message id.
$gid = 'G52CB4432576C8'; // group id.
$rest->cancel($mid); // if $gid is exists. ex) $rest-cancel(null, $gid);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get 'api.coolsms.co.kr' response code
}

View file

@ -0,0 +1,29 @@
<?php
/**
* #example_balance
*
* This sample code demonstrate how to check cash & point balance through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\Message;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new Message($api_key, $api_secret);
$result = $rest->getBalance();
print_r($result);
} catch (CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,35 @@
<?php
/**
* #example_sent
*
* This sample code demonstrate how to check sms result through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\Message;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new Message($api_key, $api_secret);
// set necessary options
$options = new stdClass();
// $options->count = '1'; // 기본값 1이며 1개의 최신 레코드를 받을 수 있음. 10입력시 10분동안의 레코드 목록을 리턴
// $options->unit = 'minute'; // minute(default), hour, day 중 하나 해당 단위의 평균
// $options->date = '20161016230000'; // 데이터를 읽어오는 기준 시각
// $options->channel = '1'; // 1 : 1건 발송채널(default), 2 : 대량 발송 채널
$result = $rest->getStatus($options);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,52 @@
<?php
/**
* #example_send
*
* This sample code demonstrate how to send sms through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\Message;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new Message($api_key, $api_secret);
// 4 options(to, from, type, text) are mandatory. must be filled
$options = new stdClass();
$options->to = '01000000000'; // 수신번호
$options->from = '01000000000'; // 발신번호
$options->type = 'SMS'; // Message type ( SMS, LMS, MMS, ATA )
$options->text = '안녕하세요. 10000건을 20초안에 발송하는 빠르고 저렴한 CoolSMS의 테스팅 문자입니다. '; // 문자내용
// Optional parameters for your own needs
// $options->image = '../Image/images/test.jpg'; // image for MMS. type must be set as 'MMS'
// $options->image_encoding = 'binary'; // image encoding binary(default), base64
// $options->mode = 'test'; // 'test' 모드. 실제로 발송되지 않으며 전송내역에 60 오류코드로 뜹니다. 차감된 캐쉬는 다음날 새벽에 충전 됩니다.
// $options->delay = 10; // 0~20사이의 값으로 전송지연 시간을 줄 수 있습니다.
// $options->force_sms = true; // 푸시 및 알림톡 이용시에도 강제로 SMS로 발송되도록 할 수 있습니다.
// $options->refname = ''; // Reference name
// $options->country = 'KR'; // Korea(KR) Japan(JP) America(USA) China(CN) Default is Korea
// $options->datetime = '20140106153000'; // Format must be(YYYYMMDDHHMISS) 2014 01 06 15 30 00 (2014 Jan 06th 3pm 30 00)
// $options->mid = 'mymsgid01'; // set message id. Server creates automatically if empty
// $options->gid = 'mymsg_group_id01'; // set group id. Server creates automatically if empty
// $options->subject = 'Hello World'; // set msg title for LMS and MMS
// $options->charset = 'euckr'; // For Korean language, set euckr or utf-8
// $options->sender_key = '55540253a3e61072...'; // 알림톡 사용을 위해 필요합니다. 신청방법 : http://www.coolsms.co.kr/AboutAlimTalk
// $options->template_code = 'C004'; // 알림톡 template code 입니다. 자세한 설명은 http://www.coolsms.co.kr/AboutAlimTalk을 참조해주세요.
// $options->app_version = 'Purplebook 4.1' // 어플리케이션 버전
$result = $rest->send($options);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,38 @@
<?php
/**
* #example_sent
*
* This sample code demonstrate how to check sms result through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\Message;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new Message($api_key, $api_secret);
// set necessary options
$options = new stdClass();
$options->message_id = 'M52CB443257C61'; //message id
// $options->group_id = 'G52CB4432576C8'; //group id
// $options->count = '40'; //result return counts. default is 20
// $options->page = '1'; //page
// $options->rcpt = '01012345678'; //search sent result by recipient number
// $options->start = '201401070915'; //set search start date ex) 201401070915
// $options->end = '201401071230'; //set search end date ex) 201401071230
$result = $rest->sent($options);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,31 @@
<?php
/**
* #example_delete_images
*
* This sample code demonstrate how to delete images through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\Image;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new Image($api_key, $api_secret);
// image_ids are mandatory. must be filled
$image_ids = ''; // image ids. ex)'IM34BWIDJ12','IMG2559GBB'
$result = $rest->deleteImages($image_ids);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,31 @@
<?php
/**
* #example_image_info
*
* This sample code demonstrate how to check image info through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\Image;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new Image($api_key, $api_secret);
// image_id are mandatory. must be filled
$image_id = ''; // image id
$result = $rest->getImageInfo($image_id);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,32 @@
<?php
/**
* #example_image_list
*
* This sample code demonstrate how to check image list through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\Image;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new Image($api_key, $api_secret);
// Optional parameters for your own needs
$offset = 0; // default 0
$limit = 20; // default 20
$result = $rest->getImageList($offset, $limit);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,34 @@
<?php
/**
* #example_upload_image
*
* This sample code demonstrate how to upload image through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\Image;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new Image($api_key, $api_secret);
// image are mandatory. must be filled
$image = 'images/test.jpg'; // image
// Optional parameters for your own needs
// $encoding = 'binary'; // image encoding type (base64, binary) default binary
$result = $rest->uploadImage($image); // or $rest->uploadImage($image, $encoding)
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View file

@ -0,0 +1,31 @@
<?php
/**
* #example_delete
*
* This sample code demonstrate how to delete sender number through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\SenderID;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new SenderID($api_key, $api_secret);
// handle_key are mandatory. must be filled
$handle_key = 'C29CE02IOE9'; // sender number handle key. check for 'example_list'
$result = $rest->delete($handle_key);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,31 @@
<?php
/**
* #example_get_default
*
* This sample code demonstrate how to get default sender number through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\SenderID;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new SenderID($api_key, $api_secret);
// Optional parameters for your own needs
// $site_user = 'admin'; // site user_id. '__private__' is default value
$result = $rest->getDefault(); // or $rest->getDefault($site_user);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,31 @@
<?php
/**
* #example_list
*
* This sample code demonstrate how to check sender number list through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\SenderID;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new SenderID($api_key, $api_secret);
// Optional parameters for your own needs
// $site_user = 'admin'; // site user_id. '__private__' is default value
$result = $rest->getSenderidList(); // or $rest->senderidList($site_user);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,34 @@
<?php
/**
* #example_register
*
* This sample code demonstrate how to request sender number register through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\SenderID;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new SenderID($api_key, $api_secret);
// phone are mandatory. must be filled
$phone = '01000000000'; // sender number to register
// Optional parameters for your own needs
// $site_user = 'admin'; // site user_id. '__private__' is default value
$result = $rest->register($phone); // or $rest->register($phone, $site_user);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,34 @@
<?php
/**
* #example_set_default
*
* This sample code demonstrate how to set default sender number through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\SenderID;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new SenderID($api_key, $api_secret);
// handle_key are mandatory. must be filled
$handle_key = 'C29CE02IOE9'; // sender number handle key. check for 'example_list'
// Optional parameters for your own needs
// $site_user = 'admin'; // site user_id. '__private__' is default value
$result = $rest->setDefault($handle_key); // or $rest->setDefault($handle_key, $site_user);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}

View file

@ -0,0 +1,31 @@
<?php
/**
* #example_verify
*
* This sample code demonstrate how to verify sender number through CoolSMS Rest API PHP
* for more info, visit
* www.coolsms.co.kr
*/
use Nurigo\Api\SenderID;
use Nurigo\Exceptions\CoolsmsException;
require_once __DIR__ . "/../../bootstrap.php";
// api_key and api_secret can be obtained from www.coolsms.co.kr/credentials
$api_key = '#ENTER_YOUR_OWN#';
$api_secret = '#ENTER_YOUR_OWN#';
try {
// initiate rest api sdk object
$rest = new SenderID($api_key, $api_secret);
// handle_key are mandatory. must be filled
$handle_key = 'C29CE02IOE9'; // after register call. return value
$result = $rest->verify($handle_key);
print_r($result);
} catch(CoolsmsException $e) {
echo $e->getMessage(); // get error message
echo $e->getCode(); // get error code
}