hongyukeji / php-sms
Requires
- php: >=5.3.0
- guzzlehttp/guzzle: ^6.3|^7.0
README
全网首款支持所有短信服务商,自由扩展,无缝对接。
采用Hongyukeji专利《宏观设计模式》开发。
更多请点击 http://www.hongyuvip.com
特点
- 支持全网络短信服务商
- 支持自由扩展且易维护
支持
- 阿里云
- 云片网
- 腾讯云
- 短信宝
- 赛邮云通信
- SendCloud
- 互亿无线
- 创蓝253
- 螺丝帽
- 华信云通信
- 华为云
- 百度云
- 七牛云
- 云之讯
- 凯信通
- 聚合数据
- 阿凡达数据
- 网易云信
- 容联云通讯
- 优刻得
- 上述短信服务商比较常用,其他短信如有需要可联系Hongyukeji集成
- 如需支持其他短信服务商,可以自行Fork,在
src/Sms.php
中添加对应的短信发送方法即可 - 短信快速集成(参考《宏观设计模式》 — Hongyukeji出品)
环境
- PHP >= 5.3.0
安装
$ composer require hongyukeji/php-sms
使用
PHP框架中使用,配置文件参考 'config/sms.php'
短信发送参数详解: send([参数1-手机号: 支持字符串和数组格式],[参数2-模板: 支持模板Code和模板内容],[参数3-模板参数: 模板对应的参数, 数组格式],[参数4-短信服务商: 设置短信发送服务商, 该参数为空时调用配置文件中默认短信服务商])
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' => '短信发送成功!',
];
维护
- Author:Hongyukeji
- QQ:1275588965
- Email:hongyukeji@qq.com
配置
使用说明:template_code + template_params
'aliyun' => [
'accessKeyId' => '',
'accessKeySecret' => '',
'signName' => '',
'driver' => 'Hongyukeji\\PhpSms\\Gateways\\AliyunGateway',
],
使用说明:template_code + template_params
'yunpian' => [
'apikey' => '',
'driver' => 'Hongyukeji\\PhpSms\\Gateways\\YunpianGateway',
],
使用说明:template_code + template_params
'qcloud' => [
'appid' => '',
'appkey' => '',
'smsSign' => '',
'driver' => 'Hongyukeji\\PhpSms\\Gateways\\QcloudGateway',
],
使用说明:template_content + template_params
'duanxinbao' => [
'user' => '',
'pass' => '',
'signName' => '',
'driver' => 'Hongyukeji\\PhpSms\\Gateways\\DuanxinbaoGateway',
],
使用说明:template_code + template_params
'submail' => [
'appid' => '',
'appkey' => '',
'driver' => 'Hongyukeji\\PhpSms\\Gateways\\SubmailGateway',
],
使用说明:template_code + template_params
'sendcloud' => [
'sms_user' => '',
'sms_key' => '',
'driver' => 'Hongyukeji\\PhpSms\\Gateways\\SendCloudGateway',
],
使用说明:template_content + template_params
'ihuyi' => [
'apiid' => '',
'apikey' => '',
'driver' => 'Hongyukeji\\PhpSms\\Gateways\\IhuyiGateway',
],
使用说明:template_content + template_params
'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
'luosimao' => [
'sms_name' => '螺丝帽',
'sms_url' => 'https://luosimao.com',
'api_key' => '',
'driver' => 'Hongyukeji\\PhpSms\\Gateways\\LuosimaoGateway',
],
使用说明:template_content + template_params
'huaxin' => [
'sms_name' => '华信云通信',
'sms_url' => 'https://luosimao.com',
'account' => '',
'password' => '',
'driver' => 'Hongyukeji\\PhpSms\\Gateways\\LuosimaoGateway',
],
使用说明:template_code + template_params
'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
'baidu' => [
'sms_name' => '百度云',
'sms_url' => 'https://cloud.baidu.com/',
'invokeId' => '',
'ak' => '',
'sk' => '',
'driver' => 'Hongyukeji\\PhpSms\\Gateways\\BaiduGateway',
],
使用说明:template_code + template_params
'qiniu' => [
'sms_name' => '七牛云',
'sms_url' => 'https://www.qiniu.com/products/sms',
'access_key' => '',
'secret_key' => '',
'driver' => 'Hongyukeji\\PhpSms\\Gateways\\QiniuGateway',
],
使用说明:template_code + template_params
'yunzhixun' => [
'sms_name' => '云之讯',
'sms_url' => 'https://www.ucpaas.com/index.html',
'app_id' => '',
'token' => '',
'sid' => '',
'driver' => 'Hongyukeji\\PhpSms\\Gateways\\YunzhixunGateway',
],
使用说明:template_content + template_params
'kaixintong' => [
'sms_name' => '凯信通',
'sms_url' => 'http://www.kingtto.cn',
'account' => '',
'password' => '',
'userid' => '',
'driver' => 'Hongyukeji\\PhpSms\\Gateways\\KaixintongGateway',
],
使用说明:template_code + template_params
'juhe' => [
'sms_name' => '聚合数据',
'sms_url' => 'https://www.juhe.cn',
'key' => '',
'driver' => 'Hongyukeji\\PhpSms\\Gateways\\JuheGateway',
],
使用说明:template_code + template_params
'afanda' => [
'sms_name' => '阿凡达数据',
'sms_url' => 'https://www.avatardata.cn',
'key' => '',
'driver' => 'Hongyukeji\\PhpSms\\Gateways\\AfandaGateway',
],
使用说明:template_code + template_params
'wangyiyunxin' => [
'sms_name' => '网易云信',
'sms_url' => 'https://yunxin.163.com/sms',
'app_key' => '',
'app_secret' => '',
'driver' => 'Hongyukeji\\PhpSms\\Gateways\\WangyiYunxinGateway',
],
使用说明:template_code + template_params
'rongliancloud' => [
'sms_name' => '容联云通讯',
'sms_url' => 'https://www.yuntongxun.com/',
'app_key' => '',
'app_secret' => '',
'driver' => 'Hongyukeji\\PhpSms\\Gateways\\RonglianGateway',
],
使用说明:template_code + template_params
'ucloud' => [
'sms_name' => '优刻得',
'sms_url' => 'https://www.ucloud.cn',
'private_key' => '',
'public_key' => '',
'sig_content' => '',
'project_id' => '',
'driver' => 'Hongyukeji\\PhpSms\\Gateways\\RonglianCloudGateway',
],