仅供参考
接口文档api地址:https://www.globalsms.cn/api.html
需要注意的点:
- 时间点的获取及md5加密
- 内容的urlencode编码 post请求
- 数据以json方式提交
#!python3
#sms api test
import time, hashlib, urllib, urllib.parse, urllib.request, json, requests
headers = {'Content-Type': 'application/json;charset=UTF-8'}
for i in range(6):
time.sleep(5)
account = 'xxxxx'
password = 'xxxxx'
senderid = 'xxxxx'
time_str = time.strftime('%Y%m%d%H%M%S',time.localtime(time.time()))
sign_str = account+password+time_str
m = hashlib.md5()
b = sign_str.encode(encoding='utf-8')
m.update(b)
sign = m.hexdigest()
numbers = '84123456789'
content = 'hello, test.'
#python3.0后的编码器urlencode更新后改为quote_plus data = urllib.parse.urlencode(values)
content = urllib.parse.quote_plus(conte