maxwelldu/yii2-sms

v1.1 2016-04-20 08:15 UTC

This package is auto-updated.

Last update: 2024-12-12 05:28:51 UTC


README

Yii2 对应的短信扩展

Build StatusLatest Stable Version Total Downloads Latest Unstable Version License

Install

add maxwelldu/yii2-sms to composer.json

$ composer update

OR

$ composer require maxwelldu/yii2-sms

Configurtion

\# file app/config/main.php
<?php

return [
    'components' => [
	   'sms' => [
            'class' => 'maxwelldu\\sdk\\Chuanglan',
            'apiAccount' => 'your chuanglan apiAccount',
            'apiPassword' => 'your chuanglan apiPassword',
            'apiSendUrl' => 'http://222.73.117.156/msg/HttpBatchSendSM',
            'apiBalanceQueryUrl' => 'http://222.73.117.156/msg/QueryBalance',
        ],
    ],
];

Usage

$phone = '18812345678';
// $phone = ['01234567890'];   # 可以为数组
// $phone = '12345678900,01234567890';  # 还可以号码与号码之间用空格隔开
$text ='sms content';
$sms = Yii::$app->sms;
if($sms->sendSms($phone, $text))
{
    //发送成功
} elseif ($sms->hasError()) {
    $error = $sms->getError()
    # "请求参数格式错误"
}

Run phpunit

composer install

please update apiAccount and apiPassword and mobile in tests/ChuanglanTest.php file

./vendor/bin/phpunit