PHP code example of maxwelldu / yii2-sms

1. Go to this page and download the library: Download maxwelldu/yii2-sms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

maxwelldu / yii2-sms example snippets


\# file app/config/main.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()
    # "请求参数格式错误"
}