亿美软通 短信api
亿美软通 短信api
国际短信http标准协议文档和demo的地址:
import datetime import random import hashlib import requests appId = "亿美软通的app_id" url = "http://bjksmtn.b2m.cn/simpleinter/sendSMS" secretKey = "亿美软通的秘钥" def getDateTime(): # 获取yyyyMMddhhmmssSSS格式时间戳 signtime = datetime.datetime.now().strftime('%Y%m%d%H%M%S%f')[0:17] # print(signtime) return signtime now_time = str(getDateTime()) def createCode(): return random.randint(0, 9) def code(): ret = str(createCode()) + str(createCode()) + str(createCode()) + str(createCode()) return ret c = code() content = "【全城交友】验证码" + c + ",您正在登录,若非本人操作,请勿泄露!" mobile = '18611111111' m = appId+secretKey+now_time m=hashlib.md5(m.encode(encoding='utf-8')).hexdigest() print(m) payload = { "appId": appId, "timestamp": now_time, "sign": m, "mobiles": mobile, "content": content, } # 2-json参数会自动将字典类型的对象转换为json格式 r1 = requests.get(url, params=payload) res = r1.json() print(res)
结果:'code': 'SUCCESS' 表示成功调用