zoukankan      html  css  js  c++  java
  • python 调用接口发短信

    调用接口发送短信

    此处接口是移动云nas

    """
    Create_of_date:2020-03-08
    Author:nod
    description:
    调用移动云mas接口
    exchange_date         author               exchange
    
    """
    from flask import request, Flask, jsonify
    import hashlib
    import base64
    import json
    import requests
    url='http://112.XXX.XXX:5992/sms/norsubmit'
    
    app = Flask(__name__)
    app.config['JSON_AS_ASCII'] = False
    
    @app.route('/test', methods=['POST'])
    def post_Data():
        #接收传递进来的mobiles & content参数 如果第三方接口调用参数指定了这里mobile content可以进行修改
        mobile = request.form['mobile']
        content = request.form['content']
        #传递进来的参数构造字典
        dicinfo = {'mobiles': mobile, 'content': content}
        mob=dicinfo['mobiles']
        con=dicinfo['content']
        #取值转换成字符串---> md5 小写
        mes='常州市XX****cz**1cz**1@**3'+mob+con+'439I8a8aR'
        m=hashlib.md5()
        m.update(mes.encode('utf-8'))
        md5_info=m.hexdigest()
        #构造转换前的base64字典
        base64_before={"ecName":"常州市XXX院1", "apId":"czxx1", "secretKey":"czxxxx23", "mobiles":mob, "content":con,
     "sign":"43xxxaR", "addSerial":"", "mac":md5_info}
        #字典转json
        base_json=json.dumps(base64_before)
        base64_end=base64.b64encode(base_json.encode('utf-8'))
        #### 去除byte
        byte_end=str(base64_end,'utf-8')
        print(byte_end)
        req = requests.post(url, data=byte_end)
        return jsonify(dicinfo), 201
    
    if __name__ == '__main__':
        app.run(debug=False, host='127.0.0.1', port=9999)
    

      

  • 相关阅读:
    CCS3.3安装常见问题(以合众达的为例)
    typedef unsigned long (__stdcall *THREADFUNC)(void *)
    Prism学习(8)模块间通讯
    Prism学习(6)Shell Region View
    Prism学习(4)弃远就近UnityBootstrapper
    Prism学习(2)初识Unity
    Prism学习(5)Hello Silverlight
    Prism学习(1)前期准备
    Prism学习(7)Commands
    Prism学习(9)阶段性总结
  • 原文地址:https://www.cnblogs.com/nodchen/p/12444255.html
Copyright © 2011-2022 走看看