腾讯云短信接口调用

PHP   2024-07-17 21:44   47   0  
composer require tencentcloud/tencentcloud-sdk-php

//短信接口
public function sms(){
    $cred = new Credential("AKIDNjP4zw2LkJvaMdA9889ER2nE57RwOsRz", "lavQwYdk2PvofBdG0sx5NAUwjkxDToRz");
    $httpProfile = new HttpProfile();
    $httpProfile->setReqMethod("GET");  // get请求(默认为post请求)
    $httpProfile->setReqTimeout(10);    // 请求超时时间,单位为秒(默认60秒)
    $httpProfile->setEndpoint("sms.tencentcloudapi.com");  // 指定接入地域域名(默认就近接入)
    $clientProfile = new ClientProfile();
    $clientProfile->setSignMethod("TC3-HMAC-SHA256");  // 指定签名算法
    $clientProfile->setHttpProfile($httpProfile);
    $client = new SmsClient($cred, "ap-guangzhou", $clientProfile);
    $req = new SendSmsRequest();
    $req->SmsSdkAppId = "1400924999";
    $req->SignName = "北京";
    $req->TemplateId = "2218000";
    $req->TemplateParamSet = array("6868");
    $req->PhoneNumberSet = array("+8613666666666");
    $resp = $client->SendSms($req);
    print_r($resp->toJsonString());
    // print_r($resp->TotalCount);  //您可以通过官网接口文档或跳转到response对象的定义处查看返回字段的定义
}
博客评论
还没有人评论,赶紧抢个沙发~
发表评论
说明:请文明发言,共建和谐网络,您的个人信息不会被公开显示。