Giter Club home page Giter Club logo

aligo-sms's Introduction

Aligo, SMS

Latest Stable Version Latest Unstable Version Total Downloads License

Installation

composer require apikr/aligo-sms

공식페이지 : smartsms.aligo.in

사용법

  1. 서비스를 신청합니다.
  2. 관리자에서 "신청/인증" 메뉴에 들어갑니다.
  3. "API Key 발급신청" 버튼을 통해 발급받습니다.

sample

  1. 발신번호를 추가합니다.

그리고 다음과 같이 정의합니다.

<?php

$httpClient = new GuzzleHttp\Client();

$conf = new Apikr\Aligo\Sms\Configuration([
    'id' => 'serviceid',
    'apikey' => 'abcdefghiklmnopqrstuvwxyz',
    'sender' => '발신번호',
]);
$sms = new Apikr\Aligo\Sms\Api($httpClient, $conf);

문자전송

<?php
$result = $this->sms->send('000-1234-1234', '문자 가라 얍!');

문자 잔여량

<?php
$result = $this->sms->remain(); // 한번에 가지고 오기
$result['SMS_CNT']; // sms 남은 갯수
$result['LMS_CNT']; // lms 남은 갯수
$result['MMS_CNT']; // mms 남은 갯수

$this->sms->remainSms();
$this->sms->remainLms();
$this->sms->remainMms();

Exception

  • 모든 에러는 \Apikr\Aligo\Sms\Exception\RequestException 클래스로 처리합니다.
  • 문자 전송은 \Apikr\Aligo\Sms\Exception\SmsDeliveryException 클래스로 처리합니다.
<?php
namespace Apikr\Aligo\Sms\Exception;

class RequestException extends \RuntimeException
{
    const ERR_SERVER = -100;
    const ERR_INVALID_PARAM = -101;
    const ERR_AUTH_ERROR = -102;
    const ERR_WRONG_SENDER = -103;
    const ERR_DELIVERY_LIMIT_OR_TIME = -105;
    const ERR_INSUFFICIENT_REMAINING = -109;
    const ERR_RESERVED_DATETIME = -115;
    const ERR_REQUIRE_CHARGE = -201;
    const ERR_WRONG_IMAGE = -301;
    const ERR_UNKNOWN = -900;

    public function getResult();
}

class SmsDeliveryException extends RequestException
{
    public function getReceiver();
    public function getText();
}

aligo-sms's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.