laravel 阿里云短信验证码

1.安装
 
  1.  
  2. composer require hyperbolaa/alisms dev-master

 2.laravel配置
 
  1. 'providers' => [

  2. // ...

  3. Hyperbolaa\Alisms\AlismsServiceProvider::class,

  4. ]

 
  1. 3.运行 `php artisan vendor:publish` 命令,

  2. 发布配置文件到你的项目中。

4.app配置
 
  1. $alisms = app('alisms.yun');

  2. //$alisms = app('alisms.api');

  3. //$alisms = app('alisms.note');

  4. $flag = $alisms->send('register','15588888888',['code'=>'456789']);//code 为模板中的变量名

  5.  
  6. if($flag === true){

  7. //todo 发送成功处理

  8. }

5.(alisms.yun不行的话  就换成alisms.note)
 
  1. 'yun'=>[//阿里云短信

  2. 'access_key_id' => 'xxxxxx',//

  3. 'access_key_secret' => 'xxxxxx',//

  4. 'common_sign_name' => '支付宝',//普通模板签名

  5. 'spread_sign_name' => '支付宝',//推广模板签名

  6. 'template_code' => [

  7. 'register' => 'SMS_35650882',//模板名让一个变量来替换

  8. ]

  9. ],

(犯错点:1.模板消息的更改在config里面的alisms.php2.模板中的变量名称要和阿里云后台的模板详情的变量一一对应)

https://github.com/hyperbolaa/Alisms

猜你喜欢

转载自blog.csdn.net/sunjinyan_1/article/details/81088324