GithubHelp home page GithubHelp logo

yiiviet / yii2-esms Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 17 KB

Yii2 eSMS extension hổ trợ tích hợp dịch vụ esms.vn

License: BSD 3-Clause "New" or "Revised" License

PHP 100.00%
yii2 yii2-extension integrations esms yiivn sms-api

yii2-esms's Introduction

YII2 eSMS

Yii2 Extension hổ trợ bạn tích hợp dịch vụ eSMS.

Latest Stable Version Total Downloads Build Status Scrutinizer Code Quality Code Coverage Yii2

Nếu như bạn thường xuyên xây dựng hệ thống có liên quan đến sms hay voice call thì chắc hẳn eSMS là một đối tác không quá xa lạ với bạn, extension này sẽ giúp bạn tích hợp dịch vụ của eSMS vào hệ thống của bạn.

Yêu cầu

Cài đặt

Cài đặt thông qua composer nếu như đó là một khái niệm mới với bạn xin click vào đây để tìm hiểu nó.

composer require "yiiviet/yii2-esms"

hoặc thêm

"yiiviet/yii2-esms": "*"

vào phần require trong file composer.json.

Thiết lập

Sau khi cài đặt hoàn tất bạn hãy vào thư mục config mở file web.php và thêm cấu hình sau vào components:

'components' => [
    'eSMS' => [
        'class' => 'yiiviet\esms\Gateway',
        'client' => [
            'apiKey' => 'API key ban dang ky tai eSMS (phan quan ly api)',
            'secretKey' => 'Secret key ban dang ky tai eSMS (phan quan ly api)'
        ]
    ]
]

Sau khi thiết lập xong ngay lập tức bạn đã có thể giao tiếp với eSMS thông qua cú pháp sau: Yii::$app->eSMS.

Sử dụng cơ bản

1. Cách gửi tin nhắn:

    $result = Yii::$app->eSMS->sendSMS([
        'Phone' => '0909113911',
        'Content' => 'Hi Mr.Minh'
    ]);
    
    if ($result->isOk) {
        Yii::info('Send sms to Mr.Minh success! SMSID: ' . $result->SMSID);
    } else {
        Yii::warning($result->message);
    }

2. Cách gửi voice call (cuộc gọi thoại):

    Yii::$app->eSMS->sendVoice([
        'Phone' => '0909113911',
        'ApiCode' => 'xxxxxxxxxxx', // Liên hệ kỹ thuật eSMS cấp
        'ApiPass' => 'xxxxxxxxxxx'
    ]);
    
    if ($result->isOk) {
        Yii::info('Send voice call to Mr.Minh success! SMSID: ' . $result->SMSID);
    } else {
        Yii::warning($result->message);
    }    

3. Cách kiểm tra số dư tài khoản:

    $result = Yii::$app->eSMS->getBalance();
    
    if ($result->isOk) {
        Yii::info('Balance of account: ' . $result->Balance);
    } else {
        Yii::warning($result->message);
    }

4. Cách kiểm tra trạng thái tin nhắn đã gửi:

    $result = Yii::$app->eSMS->getSendStatus($SMSID);
    
    if ($result->isOk) {
        Yii::info('Sent: ' . $result->SentSuccess);
    } else {
        Yii::warning($result->message);
    }
  • $SMSID có được trong kết quả gửi sms hoặc voice call vì thế sau khi gửi tin nhắn xong bạn nên lưu lại $SMSID.

5. Cách kiểm tra trạng thái chi tiết tin nhắn đã gửi (hiển thị chi tiết từng số điện thoại):

    $result = Yii::$app->eSMS->getReceiverStatus($SMSID);
    
    if ($result->isOk) {
        Yii::info('Sent: ' . var_export($result->ReceiverList, true));
    } else {
        Yii::warning($result->message);
    }
  • $SMSID có được trong kết quả gửi sms hoặc voice call vì thế sau khi gửi tin nhắn xong bạn nên lưu lại $SMSID.

Sử dụng nâng cao

Nếu bạn muốn tìm hiểu sau hơn về các thành phần khi tạo lệnh gửi sms hoặc voice call hay các thành phần kết quả mà eSMS gửi về thì mời bạn kham khảo thêm tại tài liệu của eSMS tại đây. Tên các thành phần trong tài liệu eSMS đồng nhất với tên các thành phần (property, element key) của extension này.

yii2-esms's People

Contributors

vuongxuongminh avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.