laramall/aliyun-dysms

新版阿里大于短信接口 for laravel5.5+

v1.0.8 2017-12-28 02:01 UTC

This package is not auto-updated.

Last update: 2024-04-28 01:50:24 UTC


README

新版阿里大于短信接口的Laravel组件 for Laravel 5.5+

网址:larashuo.com

68747470733a2f2f6c6172617669702e636f6d2f696d616765732f616c696479736d732e706e67

系统要求

php >= 7.0+

laravel >= 5.5+

安装

composer require laramall/aliyun-dysms

设置配置文件

php artisan vendor:publish --provider="LaraMall\AlidySms\AlidySmsServiceProvider"

修改 config/sms.php 中的阿里大于短信相关参数

  	//id
	'ACCESS_KEY_ID'=>'',
	//秘钥
	'ACCESS_KEY_SECRET'=>'',
	//短信签名
	'signName'=>'',
	//短信模板编号
	'templateCode'=>'',
	//短信模板中变量字段
	'field'=>'number',
	//要发送的短信内容
	'content'=>rand(1000,9999),

使用

687474703a2f2f6f78356477693778692e626b742e636c6f7564646e2e636f6d2f6769746875622f736d732d74702e706e67

use Sms;

//短信发送成功 下面函数返回 true 反之 false
Sms::put('phone','13800000000')->send();

所有参数完全自定义发送短信模式

Sms::put('phone',$phone) //接受短信的手机号
   ->put('signName',$signName) //短信签名
   ->put('templateCode',$templateCode) //短信模板编号
   ->put('filed',$field) //短信模板中的变量字段
   ->put('content',$content) //短信中的变量的值 也就是验证码的内容
   ->send(); //发送短信

如果在配置文件config/sms.php中已经设置了

短信签名 + 短息模板编号 + 短信模板中字段变量 + 短信发送内容

可以使用简约模式发送短信

use Sms;
Sms::put('phone',$phone)->send();

验证短信已写入表单验证规则

假设表单中短信验证码的字段为 code

$rules = ['code'=>'required|sms'];