config['secret_id'], $this->config['secret_key']); // 实例化一个http选项,可选的,没有特殊需求可以跳过 $httpProfile = new HttpProfile(); $httpProfile->setEndpoint("sms.tencentcloudapi.com"); // 实例化一个client选项,可选的,没有特殊需求可以跳过 $clientProfile = new ClientProfile(); $clientProfile->setHttpProfile($httpProfile); // 实例化要请求产品的client对象,clientProfile是可选的 $client = new SmsClient($cred, "ap-beijing", $clientProfile); // 实例化一个请求对象,每个接口都会对应一个request对象 $req = new SendSmsRequest(); $params = array( // 数组 "PhoneNumberSet" => $mobile_phone, "SmsSdkAppId" => $this->config['sdk_app_id'], "SignName" => $sign_name, "TemplateId" => $template_id, "TemplateParamSet" => $template_param ); $req->fromJsonString(json_encode($params)); // 返回的resp是一个SendSmsResponse的实例,与请求对象对应 $resp = $client->SendSms($req); // 输出json格式的字符串回包 $resp = $resp->toJsonString(); $result = json_decode($resp, true); // 记录日志 $uid = defined('UID') ? UID : ''; platformLog($params, $result, 'tencent_message_send_sms_uid_' . $uid); return $result; } catch (TencentCloudSDKException $e) { echo $e; } } }