This is a SMS sending component.
全网首款支持所有短信服务商,自由扩展,无缝对接。, (*1)
采用Hongyukeji专利《宏观设计模式》开发。, (*2)
更多请点击 http://www.hongyuvip.com, (*3)
src/Sms.php
中添加对应的短信发送方法即可$ composer require hongyukeji/php-sms
PHP框架中使用,配置文件参考 'config/sms.php', (*5)
短信发送参数详解: send([参数1-手机号: 支持字符串和数组格式],[参数2-模板: 支持模板Code和模板内容],[参数3-模板参数: 模板对应的参数, 数组格式],[参数4-短信服务商: 设置短信发送服务商, 该参数为空时调用配置文件中默认短信服务商]), (*6)
use Hongyukeji\PhpSms\Sms; $config = [ 'default' => 'aliyun', 'gateways' => [ 'yunpian' => [ 'apikey' => '', ], 'aliyun' => [ 'accessKeyId' => '', 'accessKeySecret' => '', 'signName' => '', ], 'qcloud' => [ 'appid' => '', 'appkey' => '', 'smsSign' => '', ], 'duanxinbao' => [ 'user' => '', 'pass' => '', 'signName' => '', ], 'submail' => [ 'appid' => '', 'appkey' => '', ], 'sendcloud' => [ 'sms_user' => '', 'sms_key' => '', ], 'ihuyi' => [ 'apiid' => '', 'apikey' => '', ], // Other... ], ]; // 初始化短信类 $sms = new Sms($config); // 模板CODE + 模板参数 // template_code + template_params $result_template_code = $sms->send('13800138000', 'SMS_88888888', [ 'code' => '1234', 'time' => '15分钟', ]); var_dump($result_template_code); // 模板内容 + 模板参数 // template_content + template_params $result_template_content = $sms->send(['13800138000', '13900139000'], '您的验证码是%s。有效期为%s,请尽快验证!', [ 'code' => '1234', 'time' => '15分钟', ], 'duanxinbao'); var_dump($result_template_content); // $result 结果返回值说明 // code: 0 => 短信发送成功, 1 => 短信发送失败 $result = [ 'code' => '0', 'message' => '短信发送成功!', ];
使用说明:template_code + template_params, (*7)
'aliyun' => [ 'accessKeyId' => '', 'accessKeySecret' => '', 'signName' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\AliyunGateway', ],
使用说明:template_code + template_params, (*8)
'yunpian' => [ 'apikey' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\YunpianGateway', ],
使用说明:template_code + template_params, (*9)
'qcloud' => [ 'appid' => '', 'appkey' => '', 'smsSign' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\QcloudGateway', ],
使用说明:template_content + template_params, (*10)
'duanxinbao' => [ 'user' => '', 'pass' => '', 'signName' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\DuanxinbaoGateway', ],
使用说明:template_code + template_params, (*11)
'submail' => [ 'appid' => '', 'appkey' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\SubmailGateway', ],
使用说明:template_code + template_params, (*12)
'sendcloud' => [ 'sms_user' => '', 'sms_key' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\SendCloudGateway', ],
使用说明:template_content + template_params, (*13)
'ihuyi' => [ 'apiid' => '', 'apikey' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\IhuyiGateway', ],
使用说明:template_content + template_params, (*14)
'chuanglan' => [ 'api_send_url' => '', 'api_variable_url' => '', 'api_balance_query_url' => '', 'api_account' => '', 'api_password' => '', 'sms_sign' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\ChuanglanGateway', ],
使用说明:template_content + template_params, (*15)
'luosimao' => [ 'sms_name' => '螺丝帽', 'sms_url' => 'https://luosimao.com', 'api_key' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\LuosimaoGateway', ],
使用说明:template_content + template_params, (*16)
'huaxin' => [ 'sms_name' => '华信云通信', 'sms_url' => 'https://luosimao.com', 'account' => '', 'password' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\LuosimaoGateway', ],
使用说明:template_code + template_params, (*17)
'huawei' => [ 'sms_name' => '华为云', 'sms_url' => 'https://www.huaweicloud.com/product/msgsms.html', 'app_key' => '', 'app_secret' => '', 'sms_sign' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\HuaweiGateway', ],
使用说明:template_code + template_params, (*18)
'baidu' => [ 'sms_name' => '百度云', 'sms_url' => 'https://cloud.baidu.com/', 'invokeId' => '', 'ak' => '', 'sk' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\BaiduGateway', ],
使用说明:template_code + template_params, (*19)
'qiniu' => [ 'sms_name' => '七牛云', 'sms_url' => 'https://www.qiniu.com/products/sms', 'access_key' => '', 'secret_key' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\QiniuGateway', ],
使用说明:template_code + template_params, (*20)
'yunzhixun' => [ 'sms_name' => '云之讯', 'sms_url' => 'https://www.ucpaas.com/index.html', 'app_id' => '', 'token' => '', 'sid' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\YunzhixunGateway', ],
使用说明:template_content + template_params, (*21)
'kaixintong' => [ 'sms_name' => '凯信通', 'sms_url' => 'http://www.kingtto.cn', 'account' => '', 'password' => '', 'userid' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\KaixintongGateway', ],
使用说明:template_code + template_params, (*22)
'juhe' => [ 'sms_name' => '聚合数据', 'sms_url' => 'https://www.juhe.cn', 'key' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\JuheGateway', ],
使用说明:template_code + template_params, (*23)
'afanda' => [ 'sms_name' => '阿凡达数据', 'sms_url' => 'https://www.avatardata.cn', 'key' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\AfandaGateway', ],
使用说明:template_code + template_params, (*24)
'wangyiyunxin' => [ 'sms_name' => '网易云信', 'sms_url' => 'https://yunxin.163.com/sms', 'app_key' => '', 'app_secret' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\WangyiYunxinGateway', ],
使用说明:template_code + template_params, (*25)
'rongliancloud' => [ 'sms_name' => '容联云通讯', 'sms_url' => 'https://www.yuntongxun.com/', 'app_key' => '', 'app_secret' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\RonglianGateway', ],
使用说明:template_code + template_params, (*26)
'ucloud' => [ 'sms_name' => '优刻得', 'sms_url' => 'https://www.ucloud.cn', 'private_key' => '', 'public_key' => '', 'sig_content' => '', 'project_id' => '', 'driver' => 'Hongyukeji\\PhpSms\\Gateways\\RonglianCloudGateway', ],