安装扩展
composer require tongso/notice-message
安装之后会在config目录里自动生成noticeMessage.php配置文件
return [ //手机短信 "shortMessage" => [ //当前使用的短信接口服务商 "defaultVendor" => "aliyun", //各服务商接口参数配置,每个服务商接口验证参数可能不一样 "apiConfigs" => [ "aliyun" => [ "accessKeyId" => '', "accessSecret" => '', "signName" => 'MrByte.cn', "regionId" => 'cn-hangzhou',//阿里默认值 "host" => 'dysmsapi.aliyuncs.com'//阿里默认值 ], "juhe" => [ "apiKey" => '' ] ] ] ];
使用方法
//NoticeMessage::sendSms("手机号码", "短信模板ID", "短信模板中的变量值", "短信服务商名称"); NoticeMessage::sendSms('18888888888','SMS_77560091',['code'=>'123'],'aliyun');
调用参数说明
1、短信模板中的变量值:是一个key为变量名值为变量值的数组,例:array('code' => '3420') 2、短信服务商名称:目前只支持aliyun和juhe