maxwelldu / yii2-sms
yii2-sms expand
v1.1
2016-04-20 08:15 UTC
Requires
- php: >=5.3.0
- yiisoft/yii2: ^2.0
Requires (Dev)
- phpunit/phpunit: 4.5.*
This package is auto-updated.
Last update: 2024-12-12 05:28:51 UTC
README
Yii2 对应的短信扩展
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