企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
​ 部分参考这个博客:[Fastadmin阿里云短信发送简单实现\_u013787599的博客-CSDN博客](https://blog.csdn.net/u013787599/article/details/103494952 "Fastadmin阿里云短信发送简单实现_u013787599的博客-CSDN博客") 第一步:安装腾讯云插件 第二步:\\application\\tags.php   添加一行   ~~~php //自定义发送短信 'sms_send' =>[ // 'app\\api\\hook\\Sms' 'addons\\qcloudsms\\library\\SmsSingleSender' ], ~~~ ![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "点击并拖拽以移动") 完整的 tags.php 文件: ~~~php <?php // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- // | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st <liu21st@gmail.com> // +---------------------------------------------------------------------- // 应用行为扩展定义文件 return [ // 应用初始化 'app_init' => [], // 应用开始 'app_begin' => [], // 应用调度 'app_dispatch' => [ 'app\\common\\behavior\\Common', ], // 模块初始化 'module_init' => [ 'app\\common\\behavior\\Common', ], // 插件开始 'addon_begin' => [ 'app\\common\\behavior\\Common', ], // 操作开始执行 'action_begin' => [], // 视图内容过滤 'view_filter' => [], // 日志写入 'log_write' => [], // 应用结束 'app_end' => [], //自定义发送短信 'sms_send' =>[ // 'app\\api\\hook\\Sms' 'addons\\qcloudsms\\library\\SmsSingleSender' ], ]; ~~~ ![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "点击并拖拽以移动") 第三步:补充腾讯云插件的配置: ![](https://img-blog.csdnimg.cn/20200917112135816.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM0MDUwMzYw,size_16,color_FFFFFF,t_70)![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "点击并拖拽以移动")​编辑 第四步:改写腾讯云短信发送SDK部分代码  \\addons\\qcloudsms\\library\\SmsSingleSender.php ~~~php // public function __construct($appid, $appkey) // { // $this->url = "https://yun.tim.qq.com/v5/tlssmssvr/sendsms"; // $this->appid = $appid; // $this->appkey = $appkey; // $this->util = new SmsSenderUtil(); // } public function __construct() { $this->url = "https://yun.tim.qq.com/v5/tlssmssvr/sendsms"; $this->appid = get_addon_config('qcloudsms')['appid']; $this->appkey = get_addon_config('qcloudsms')['appkey']; $this->util = new SmsSenderUtil(); } ~~~ ![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "点击并拖拽以移动") 新增一个方法: ~~~php function smsSend($sms) { return $this->sendWithParam("86", $sms->mobile, get_addon_config('qcloudsms')['template']['register'], [$sms->code], get_addon_config('qcloudsms')['sign'], "", ""); } ~~~ ![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "点击并拖拽以移动") 步骤就这么多,然后短信就可以使用腾讯云短信了 ​