基于Python的短信接口调用代码示例

2022-05-20 02:32:12   第一文档网     [ 字体: ] [ 阅读: ] [ 文档下载 ]
说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。下载word有问题请添加QQ:admin处理,感谢您的支持与谅解。点击这里给我发消息

#第一文档网# 导语】以下是®第一文档网的小编为您整理的《基于Python的短信接口调用代码示例》,欢迎阅读!
示例,调用,接口,基于,代码

短信平台免费试用 注册送100+短信 www.shmiaosai.com

基于Python的短信接口调用代码示例

这篇文章主要为大家分享Python短信接口代码,Python短信发送、Python批量发送、Python短信验证码发送,感兴趣的小伙伴们可以参考一下。

功能:Python短信发送、Python批量发送、Python短信验证码 用途:短信验证码、会员营销短信、各类通知短信

注意事项:该代码仅供接入秒赛短信接口参考使用,客户可根据实际需要自行编写; #!/usr/local/bin/python #-*-coding:utf-8-*-

# Desc: 短信http接口的python代码调用示例

# https访问,需要安装 openssl-devel库。apt-get install openssl-devel import httplib import urllib import json

#服务地址,请咨询客服 sms_host = "xxxxxxxxxx" #端口号 port = 80

#发送uri,请咨询客服 send_uri = "xxxxxxxxxxx"

def send(account,pswd, content, mobile): """


短信平台免费试用 注册送100+短信 www.shmiaosai.com

发送短信 """

params = urllib.urlencode({'account': account,'pswd': pswd, 'msg': msg, 'mobile':mobile, 'needstatus':'true', 'product':''}

headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

conn = httplib.HTTPSConnection(sms_host, port=port, timeout=30) conn.request("POST", send_uri, params, headers) response = conn.getresponse() response_str = response.read() conn.close() return response_str if __name__ == '__main__': #账号

account = "***************"; #密码

pswd = "***************"; #修改为您要发送的手机号 mobile = "***************";


短信平台免费试用 注册送100+短信 www.shmiaosai.com



# 发送短信

# 修改为您要发送的短信内容

msg="【秒赛科技】您的验证码是:1234";

#print send(account,pswd,msg,mobile)




本文来源:https://www.dywdw.cn/e7624ffddc88d0d233d4b14e852458fb770b38a3.html

相关推荐
推荐阅读