赞
踩
接口、参数等需要通过移动云MAS平台注册获取
- import base64
- import hashlib
- import json
- import urllib3
-
- content_a = {
- "ecName": "用户名",
- "apId": "接口id",
- "secretKey": "接口密码",
- "mobiles": "接收号码",
- "content": "测试短信(输入自己的短信内容,可自定义模板)",
- "sign": "短信签名",
- "addSerial": "",
- "mac": ""
- }
- # md5
- m_mac = hashlib.md5()
- m_mac_cont = content_a['ecName'] + content_a['apId'] + content_a['secretKey'] + content_a['mobiles'] \
- + content_a['content'] + content_a['sign'] + content_a['addSerial']
-
- m_mac.update(m_mac_cont.encode('utf-8'))
- content_a["mac"] = (m_mac.hexdigest()).lower()
-
- http_pool = urllib3.PoolManager(cert_reqs='CERT_NONE')
- # base64编码加密
- encoding_content = base64.b64encode(json.dumps(content_a).encode('utf-8'))
- strs = str(encoding_content, 'utf-8')
-
- response = http_pool.request("POST", "http://112.35.1.155:1992/sms/norsubmit",
- body=strs, headers={'Content-Type': 'application/json', 'charset': 'UTF-8'})
最后可以通过print()进行验证
print(response.status) print(response.data)print(response.status):查看发送状态
print(response.data):查看发送数据内容
附:Postman调试脚本供开发者参考
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。