buddysoft / yii2-sms
A simple API to implement SMS Verification Code by YunPian.com
Installs: 123
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
Type:yii2-extension
Requires
- php: >=5.6.15
- yiisoft/yii2: ^2.0.45
README
sms service originally supporting YunPian
Install
composer require buddysoft/yii2-sms dev-master
导入 sms 表
./yii migrate --migrationPath=@buddysoft/sms/migrations
Yii2 项目配置
在 main.php 数组根目录下(跟 components 同级)添加类似配置:
'controllerMap' => [
// 短信验证,需要 composer require buddysoft/yii2-sms "~1.0.4"
'sms' => [
'class' => 'buddysoft\sms\controllers\SmsController',
'smsKey' => '6f32f42e37100d',
'smsTemplate' => '【购物助手】您的验证码为:#code#,请在10分钟内完成验证。如非本人操作,请忽略。',
'enableCsrfValidation' => false,
],
],
使用
发短信:
- 类型:POST
- 地址:/sms/send
- 参数:mobile, pseudo
支持 pseudo 选项,并不真正调用短信发送服务,但会将生成的验证码返回给请求者。
v1.1.3:要打开 pseudo 选项,必须配置 Yii::$app->params['pseudoSms'] 参数。
验证短信:
- 类型:POST
- 地址:/sms/verify
- 参数:mobile, code