|
@@ -2,11 +2,9 @@
|
|
|
namespace app\common\server;
|
|
|
|
|
|
use TencentCloud\Common\Credential;
|
|
|
-// 导入要请求接口对应的Request类
|
|
|
use TencentCloud\Common\Exception\TencentCloudSDKException;
|
|
|
use TencentCloud\Common\Profile\ClientProfile;
|
|
|
use TencentCloud\Common\Profile\HttpProfile;
|
|
|
-// 导入可选配置类
|
|
|
use TencentCloud\Sms\V20210111\Models\SendSmsRequest;
|
|
|
use TencentCloud\Sms\V20210111\SmsClient;
|
|
|
|
|
@@ -18,7 +16,7 @@ class tencentcloudserver
|
|
|
"SecretId" => 'AKIDRhiSv84j8H9j25sOdbJq77rKWR6TZOwE',
|
|
|
"SecretKey" => 'ziANIxLbbNt87pGQLzMSIr9AuObfWoth',
|
|
|
'region' => 'ap-beijing',
|
|
|
- 'endpoint' => 'ocr.tencentcloudapi.com',
|
|
|
+ 'endpoint' => 'sms.tencentcloudapi.com',
|
|
|
];
|
|
|
return $config;
|
|
|
}
|
|
@@ -34,33 +32,19 @@ class tencentcloudserver
|
|
|
* @author wj
|
|
|
* @date 2022-07-26
|
|
|
*/
|
|
|
- public function sendsms($appid, $SignName, $TemplateId, $TemplateParamSet, $PhoneNumberSet)
|
|
|
+ public function sendsms($array)
|
|
|
{
|
|
|
try {
|
|
|
$config = $this->getconfig();
|
|
|
$cred = new Credential($config['SecretId'], $config['SecretKey']);
|
|
|
+ $this->cred = $cred;
|
|
|
$httpProfile = new HttpProfile();
|
|
|
- $httpProfile->setReqMethod("GET");
|
|
|
- $httpProfile->setReqTimeout(30);
|
|
|
- $httpProfile->setEndpoint($config['endpoint']); // 指定接入地域域名(默认就近接入)
|
|
|
+ $httpProfile->setEndpoint($config['endpoint']);
|
|
|
$clientProfile = new ClientProfile();
|
|
|
- $clientProfile->setSignMethod("TC3-HMAC-SHA256"); // 指定签名算法(默认为HmacSHA256)
|
|
|
$clientProfile->setHttpProfile($httpProfile);
|
|
|
$client = new SmsClient($cred, $config['region'], $clientProfile);
|
|
|
$req = new SendSmsRequest();
|
|
|
- $req->SmsSdkAppId = $appid;
|
|
|
- $req->SignName = $SignName;
|
|
|
- $req->TemplateId = $TemplateId;
|
|
|
- $req->TemplateParamSet = $TemplateParamSet;
|
|
|
- /* 下发手机号码,采用 E.164 标准,+[国家或地区码][手机号]
|
|
|
- * 示例如:+8613711112222, 其中前面有一个+号 ,86为国家码,13711112222为手机号,最多不要超过200个手机号*/
|
|
|
- $req->PhoneNumberSet = $PhoneNumberSet;
|
|
|
- /* 用户的 session 内容(无需要可忽略): 可以携带用户侧 ID 等上下文信息,server 会原样返回 */
|
|
|
- //$req->SessionContext = "";
|
|
|
- /* 短信码号扩展号(无需要可忽略): 默认未开通,如需开通请联系 [腾讯云短信小助手] */
|
|
|
- //$req->ExtendCode = "";
|
|
|
- /* 国际/港澳台短信 SenderId(无需要可忽略): 国内短信填空,默认未开通,如需开通请联系 [腾讯云短信小助手] */
|
|
|
- //$req->SenderId = "";
|
|
|
+ $req->fromJsonString(json_encode($array));
|
|
|
$resp = $client->SendSms($req);
|
|
|
$respArray = $resp->serialize();
|
|
|
$respArray = $respArray['SendStatusSet'][0];
|