Bootstrap

tp6 阿里云短信接口 php

先去github仓库下载阿里云的短信接口sdk压缩包(因为是放在extend目录下,没有使用composer方式安装),解压之后文件如下
在这里插入图片描述
然后我们只需要api_sdk这个文件下面的内容
在这里插入图片描述
把api_sdk放到tp6根目录下的extend扩展库目录里面重命名为aliyunsms
在这里插入图片描述
接下来在tp6的common.php下面写一个函数 并且在文件头部声明需要用到的use

use Aliyun\Core\Config;
use Aliyun\Core\Profile\DefaultProfile;
use Aliyun\Core\DefaultAcsClient;
use Aliyun\Api\Sms\Request\V20170525\SendSmsRequest;
/*手机号,验证码*/
function send_sms_code($tel,$code)
{
   
    $root_path = \think\facade\App::getRootPath();
    require_once $root_path . 'extend/aliyunsms/vendor/autoload.php';
    require_once $root_path . 
;