微信咨询

微信咨询

13610*910*9

服务热线 7*24小时

电话咨询

Python对接腾讯云短信实现验证码发送功能

iamdu2020-01-03 22:38:13 浏览: 316355

官方接口使用说明:https://cloud.tencent.com/document/product/382/11672

from qcloudsms_py import SmsMultiSender
from qcloudsms_py.httpclient import HTTPError

# 短信应用 SDK AppID
appid = 1400303888  # SDK AppID 以1400开头
# 短信应用 SDK AppKey
appkey = "cb811b696b91907d98808885ce55bf09"
# 需要发送短信的手机号码
phone_numbers = ["13610091888", "13527850888", "13631362888", "13378485888"]
# 短信模板ID,需要在短信控制台中申请
template_id = 514167  # NOTE: 这里的模板 ID`7839`只是示例,真实的模板 ID 需要在短信控制台中申请
# 签名
sms_sign = "广州多和网络科技有限公司"  # NOTE: 签名参数使用的是`签名内容`,而不是`签名ID`。这里的签名"腾讯云"只是示例,真实的签名需要在短信控制台中申请



msender = SmsMultiSender(appid, appkey)
params = ["5678"]# 当模板没有参数时,`params = []`
try:
  result = msender.send_with_param(86, phone_numbers,
      template_id, params, sign=sms_sign, extend="", ext="")
except HTTPError as e:
  print(e)
except Exception as e:
  print(e)
print(result)

欢迎留下你的看法

共 0 条评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注