Python实现接收企业微信接收消息

皇甫波峻
2023-12-01

想接收企业微信的消息,首先得开启验证信息API(GET请求)以及接收消息服务(POST请求)。

GET的请求参考:

企业微信验证接口API

第一部分解析POST请求:
并且解析msg_signature, time, nonce和消息体数据Body(如下代码中POST的部分)

@app.route('/blackcat/v1/receive_task', methods=['POST', 'GET'])
def receive():
    try:
        auth_verify = AuthVerify()
        if request.method == "POST":
            msg_signature = request.args.get('msg_signature')
            timestamp = request.args.get('timestamp')
            nonce = request.args.get('nonce')
            request_data = request.data
            param = auth_verify.verifi_content(msg_signature, timestamp, nonce, request_data)
            submit_task_receive.delay(param)
        if request.method == "GET":
  
 类似资料: