Files
YwxAppThink/addon/smssend/README.md
T

23 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# smssend — 生产版短信发送插件
监听 `ywxapp\library\Sms` 触发的 `SmsSend` 事件,在生产环境真正调用可配置网关下发短信。
## 与开发模式的关系
`ywxapp\service\AppService` 默认注册了一个 `SmsSend` 监听:
- **开发环境(app_debug=1**:返回 `true`(仅记录验证码到日志并回传前端 `debug_code`),不下发。
- **生产环境(app_debug=0**:返回 `null`,此时必须启用本插件,`onSend` 返回 `true` 短信才会真正发出并落库。
## 配置(后台“插件配置”)
| 配置项 | 说明 |
|--------|------|
| `api_url` | 网关地址,GET 方式提交参数 |
| `account` | 网关账号 |
| `password` | 网关密码 |
| `sign` | 短信签名(内容前缀【签名】) |
| `template`| 模板,支持 `{code}` `{mobile}` 占位 |
默认按短信宝协议判断:网关返回 `0` 表示成功。若使用其它网关,请修改 `subscribe/Sender.php`
对返回值的判定逻辑(如阿里云、腾讯云等返回 JSON,需相应解析)。