dev-master
9999999-dev阿里云短信推送,yii2-aliyun-mns
BSD-3-Clause
The Requires
by houpeng
extension yii2 yii2-aliyun-mns aliyun-mns
阿里云短信推送,yii2-aliyun-mns
阿里云、云片短信推送, (*1)
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
composer require xiaochengfu/yii2-mns "v1.0.1"
or add, (*4)
"xiaochengfu/yii2-mns": "*"
to the require section of your composer.json
file., (*5)
1.在主配置文件中增加components, (*6)
'components' => [ 'mns'=>[ 'class'=> 'xiaochengfu\mns\Module', 'config'=>[ 'aliyun'=>[ 'active'=>true, //true位开启,false为关闭 'accessId' => 'xxxx', 'accessKey' => 'xxxxxxxxx', 'endpoint' => 'http://xxxx.mns.cn-hangzhou.aliyuncs.com/', 'topicName' => 'xxx', 'smsSignName' => 'xxxx', ], 'yunpian' => [ 'active'=>false, 'apikey' => 'xxxxxx', // 请替换成您的apikey ] ] ], ]
2.在程序中使用:, (*7)
当使用云片时:, (*8)
$smsParams = '具体的消息内容';
当使用阿里云时:, (*9)
$smsParams = [ 'code'=>'xxx', 'product'=>'xxx' ];
单条发送:, (*10)
Yii::$app->mns->send('186********',$smsParams,MnsComponent::YZM);
//批量发送, (*11)
$mobile = ['phone1','phone2','phone3']; $result = Yii::$app->mns->batchSend($mobile,$smsParams,MnsComponent::YZM);
$smsParams与MnsComponent::YZM的类型要一致,这里可以根据自己的模板id自行定义规则!, (*12)
阿里云短信推送,yii2-aliyun-mns
BSD-3-Clause
extension yii2 yii2-aliyun-mns aliyun-mns