Giter Club home page Giter Club logo

yii2-sms's Introduction

Yii2 Sms component

Yii2 component for sending SMS messages through Smsc

License Latest Stable Version Latest Unstable Version Total Downloads Build Status

Support

GitHub issues.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist miserenkov/yii2-sms "^1.0"

or add

"miserenkov/yii2-sms": "^1.0"

to the require section of your composer.json file.

Configuration

To use sender, you should configure it in the application configuration like the following

'components' => [
    ...
    'sms' => [
        'class' => 'miserenkov\sms\Sms',
        'gateway' => 'smsc.ua',     // gateway, through which will sending sms, default 'smsc.ua'
        'login' => '',              // login
        'password' => '',           // password or lowercase password MD5-hash
        'senderName' => '',         // sender name
        'options' => [
            'useHttps' => true,     // use secure HTTPS connection, default true
        ],
    ],
    ...
],

Available gateways

\miserenkov\sms\Sms::GATEWAY_UKRAINE,     // smsc.ua
\miserenkov\sms\Sms::GATEWAY_RUSSIA,      // smsc.ru
\miserenkov\sms\Sms::GATEWAY_KAZAKHSTAN,  // smsc.kz
\miserenkov\sms\Sms::GATEWAY_TAJIKISTAN,  // smsc.tj
\miserenkov\sms\Sms::GATEWAY_UZBEKISTAN,  // smsc.uz
\miserenkov\sms\Sms::GATEWAY_WORLD,       // smscentre.com

Messages logging

'components' => [
    ...
    'sms' => [
        ...
        'logging' => [
            'class' => '',          // optionaly, default to miserenkov\sms\logging\Logger
            'connection' => 'db'    // string or array to database connection
            'tableName' => ''       // database table name, optionaly, default to {{%sms_log}}
        ],
        ...
    ],
    ...
],

Basic usages

Get balance

/**
 * return an float in case of successful or false in case of error 
 */
Yii::$app->sms->getBalance();

Sending message

/**
 * $phones an string for single number or array for multiple numbers
 * $message an string
 *
 * return an string sms identifier in case successful or false in case error
 */
Yii::$app->sms->send($phones, $message);

Get message status

/**
 * $id sms identifier
 * $phone phone number of recipient
 *
 * return an array [
 *      status           - status code
 *      status_message   - status message
 *      err              - error code
 *      err_message      - error message
 *      send_time        - timestamp of send
 *      cost             - message cost
 *      operator         - recipient operator
 *      region           - recipient region
 * ] in case successful or false in case error
 */
Yii::$app->sms->getStatus($id, $phone);

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.