美文网首页
记第一次使用网易云短信api

记第一次使用网易云短信api

作者: 水果皮儿 | 来源:发表于2018-11-24 11:51 被阅读0次
    # coding: utf-8
    import time
    import random
    import string
    import hashlib
    import requests
    
    def send_sms():
        api = 'https://api.netease.im/sms/sendcode.action'
        AppKey = '********'
        ctime = str(time.time())
        Nonce = ''.join(random.sample(string.ascii_letters + string.digits, 20))
        Sumstr = '*******'+Nonce+ctime
        sha = hashlib.sha1(Sumstr.encode())
        CheckSum = sha.hexdigest()
        headers = {
            "Content-Type":"application/x-www-form-urlencoded",
            "charset":"utf-8",
            "AppKey":AppKey,
            "CurTime":ctime,
            "Nonce":Nonce,
            "CheckSum":CheckSum
        }
        data = {"mobile":'*******'}
        r = requests.post(url=api, headers=headers,data=data)
        print(r)
    
    if __name__ == '__main__':
        send_sms()
    

    相关文章

      网友评论

          本文标题:记第一次使用网易云短信api

          本文链接:https://www.haomeiwen.com/subject/onweqqtx.html