larva / think-sms
The ThinkPHP SMS package.
Installs: 6 202
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: ^7.3|^8.0
- overtrue/easy-sms: ^2.0
- topthink/framework: ^6.0.0
README
This is a sms expansion for the thinkphp6
特点
- 支持目前市面多家服务商
- 一套写法兼容所有平台
- 简单配置即可灵活增减服务商
- 内置多种服务商轮询策略、支持自定义轮询策略
- 统一的返回值格式,便于日志与监控
- 自动轮询选择可用的服务商
- 更多等你去发现与改进...
平台支持
- 腾讯云 SMS
- Ucloud
- 七牛云
- SendCloud
- 阿里云
- 云片
- Submail
- 螺丝帽
- 容联云通讯
- 互亿无线
- 聚合数据
- 百度云
- 华信短信平台
- 253云通讯(创蓝)
- 融云
- 天毅无线
- 阿凡达数据
- 华为云
- 网易云信
- 云之讯
- 凯信通
- UE35.net
- 短信宝
- Tiniyo
- 摩杜云
- 融合云(助通)
- 蜘蛛云
- 融合云信
- 天瑞云
环境需求
- PHP >= 7.3
Installation
composer require larva/think-sms -vv
add the config file: config/sms.php
add config
use Overtrue\EasySms\Strategies\OrderStrategy; return [ // HTTP 请求的超时时间(秒) 'timeout' => 5.0, /* |-------------------------------------------------------------------------- | Default Setting |-------------------------------------------------------------------------- | | This option defines the default sms gateway that gets used when writing | messages to the sms. The name specified in this option should match | one of the gateways defined in the "gateways" configuration array. | */ 'default' => [ // 网关调用策略,默认:顺序调用 'strategy' => OrderStrategy::class, /* |-------------------------------------------------------------------------- | Default Gateways |-------------------------------------------------------------------------- | | This option defines the default sms gateway that gets used when writing | messages to the sms. The name specified in this option should match | one of the gateways defined in the "gateways" configuration array. | */ 'gateways' => [ ], ], /* |-------------------------------------------------------------------------- | Log Gateways |-------------------------------------------------------------------------- | | Here you may configure the sms gateways for your application. This gives | you a variety of powerful log handlers / formatters to utilize. | | Available Drivers: "aliyun", "alidayu", "yunpian", "submail", | "errorlog", "luosimao", "yuntongxun", "huyi" | "juhe", "sendcloud", "baidu", "huaxin", "chuanglan" | "rongcloud", "tianyiwuxian", "twilio", "qcloud", "avatardata" | */ 'gateways' => [ //Doc // https://github.com/overtrue/easy-sms ], ];
Use
try { $res = sms('13800138000', ['content' => '您的验证码为: 6379','template' => '259734', 'data' => [6379]]); print_r($res); } catch (InvalidArgumentException $e) { print_r($e->getMessage()); } catch (NoGatewayAvailableException $e) { print_r($e->getMessage()); }