maxwelldu/yii2-sms

yii2-sms 扩展

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

This package is auto-updated.

Last update: 2024-09-12 05:02:13 UTC


README

Yii2 短信扩展

Build StatusLatest Stable Version Total Downloads Latest Unstable Version License

安装

在 composer.json 中添加 maxwelldu/yii2-sms

$ composer update

或者

$ composer require maxwelldu/yii2-sms

配置

\# 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',
        ],
    ],
];

用法

$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()
    # "请求参数格式错误"
}

运行 phpunit

composer install

请在 tests/ChuanglanTest.php 文件中更新 apiAccount、apiPassword 和 mobile

./vendor/bin/phpunit