1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace app\common\util;
- use TencentCloud\Sms\V20210111\SmsClient;
- use TencentCloud\Sms\V20210111\Models\SendSmsRequest;
- use TencentCloud\Common\Exception\TencentCloudSDKException;
- use TencentCloud\Common\Credential;
- use TencentCloud\Common\Profile\ClientProfile;
- use TencentCloud\Common\Profile\HttpProfile;
- class TxySms
- {
-
- public static function SendSms($template_code,$phone_all){
- try {
-
- $cred = new Credential(config('tencentcloud.SecretId'), config('tencentcloud.SecretKey'));
-
- $httpProfile = new HttpProfile();
-
-
- $httpProfile->setReqMethod("GET");
- $httpProfile->setReqTimeout(30);
- $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 = config('sms.SdkAppId');
-
- $req->SignName = config('sms.sign');
-
- $req->TemplateId = config('sms.template_id');
-
- $req->TemplateParamSet = [$template_code];
-
- $req->PhoneNumberSet = ['+86'.$phone_all];
-
- $req->SessionContext = "";
-
- $req->ExtendCode = "";
-
- $req->SenderId = "";
-
-
- $resp = $client->SendSms($req);
-
- $json_data = $resp->toJsonString();
- $arr_data = json_decode($json_data,true);
- return $arr_data;
- }
- catch(TencentCloudSDKException $e) {
- echo $e->getMessage();
- }
- }
- }
|