а√在线中文网新版地址在线,播五月开心婷婷综合,午夜国产精品视频在线,√8天堂资源地址中文在线,80岁色老头oldmanvideos

注冊(cè)送短信

DEMO: SMS/Send - 短信發(fā)送

示例代碼


非加密代碼示例

import requests
import json

appid = 'appid'                             #SUBMAIL控制臺(tái)創(chuàng)建appid
appkey = 'appkey'                           #SUBMAIL控制臺(tái)獲取appkey
content = '【xxx公司】這是一條測試的短信'       #短信內(nèi)容 【xxx公司】為簽名,需要更換為公司或者產(chǎn)品名稱
to = '186xxxxxxxx'                          #手機(jī)號(hào)碼

url = 'https://api-v4.mysubmail.com/sms/send.json'

header = {"Content-type": "application/json"}
param = {
    'appid': appid,
    'signature': appkey,
    'content': content,
    'to': to
}
res = requests.post(url, data=json.dumps(param), headers=header)
print(res.json())

加密代碼示例

import hashlib
import requests
import json

appid = 'appid'                             #SUBMAIL控制臺(tái)創(chuàng)建appid
appkey = 'appkey'                           #SUBMAIL控制臺(tái)獲取appkey
content = '【xxx公司】這是一條測試的短信'       #短信內(nèi)容 【xxx公司】為簽名,需要更換為公司或者產(chǎn)品名稱
to = '186xxxxxxxx'                          #手機(jī)號(hào)碼

sign_version = '2'
sign_type = 'md5'

url = 'https://api-v4.mysubmail.com/sms/send.json'

header = {"Content-type": "application/json"}


# 獲取時(shí)間戳
def gettimestamp():
    res = requests.get('https://api-v4.mysubmail.com/service/timestamp').json()
    timestamp = str(res['timestamp'])
    return timestamp


# 參數(shù)md5計(jì)算
def getmd5(params):
    signStr = ''
    for key in sorted(params):
        signStr += key + '=' + params[key] + '&'
    signStr = signStr[:-1]
    signStr = appid + appkey + signStr + appid + appkey
    print(signStr)

    m = hashlib.md5()
    b = signStr.encode(encoding='utf-8')
    m.update(b)
    return m.hexdigest()


param = {
    'appid': appid,
    'to': to,
    'sign_version': sign_version,
    'sign_type': sign_type,
    'timestamp': gettimestamp()
}
param["signature"] = getmd5(param)
param["content"] = content

res = requests.post(url, data=json.dumps(param), headers=header)
print(res.json())