xiaochengfu/yii2-mns
Composer 安装命令:
composer require xiaochengfu/yii2-mns
包简介
阿里云、云片短信推送,yii2-mns
README 文档
README
阿里云、云片短信推送
Installation
The preferred way to install this extension is through composer.
Either run
composer require xiaochengfu/yii2-mns "v1.0.1"
or add
"xiaochengfu/yii2-mns": "*"
to the require section of your composer.json file.
Usage
1.在主配置文件中增加components
'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.在程序中使用:
当使用云片时:
$smsParams = '具体的消息内容';
当使用阿里云时:
$smsParams = [
'code'=>'xxx',
'product'=>'xxx'
];
单条发送:
Yii::$app->mns->send('186********',$smsParams,MnsComponent::YZM);
//批量发送
$mobile = ['phone1','phone2','phone3'];
$result = Yii::$app->mns->batchSend($mobile,$smsParams,MnsComponent::YZM);
$smsParams与MnsComponent::YZM的类型要一致,这里可以根据自己的模板id自行定义规则!
统计信息
- 总下载量: 34
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2017-08-05