【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《基于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.wddqxz.cn/e7624ffddc88d0d233d4b14e852458fb770b38a3.html