Ejemplo n.º 1
0
/** 
 * #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
}
Ejemplo n.º 2
0
/**
 * #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사이의 값으로 전송지연 시간을 줄 수 있습니다.
Ejemplo n.º 3
0
<?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
}
Ejemplo n.º 4
0
/**
 * #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