腾讯云短信API是提供短信发送能力的云服务接口,开发者可以通过API实现验证码、通知类短信的发送功能。该API基于HTTP/HTTPS协议,支持多种编程语言调用。
原因:
解决方案:
原因:
解决方案:
原因:
解决方案:
import json
from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.sms.v20210111 import sms_client, models
def send_sms(phone_number, template_id, template_param):
try:
cred = credential.Credential("SecretId", "SecretKey")
http_profile = HttpProfile()
http_profile.endpoint = "sms.tencentcloudapi.com"
client_profile = ClientProfile()
client_profile.httpProfile = http_profile
client = sms_client.SmsClient(cred, "ap-guangzhou", client_profile)
req = models.SendSmsRequest()
params = {
"PhoneNumberSet": [phone_number],
"SmsSdkAppId": "1400000000",
"SignName": "腾讯云",
"TemplateId": template_id,
"TemplateParamSet": template_param.split(",")
}
req.from_json_string(json.dumps(params))
resp = client.SendSms(req)
return resp.to_json_string()
except TencentCloudSDKException as err:
return err
没有搜到相关的文章