Office 2013 / 2016 / 2019 ProPlus Retail零售版密钥上架

python flask 微信公众号验证

Python

更新于:

0x00 概述

计划对接微信公众号了,配置公众号需要验证服务器


0x01 上代码

import hashlib


@bp.route("/wechat/", methods=['GET', 'POST'])
def wechat():
    _list = ["自定义设置的token", request.args.get('timestamp'), request.args.get("nonce")]
    _list.sort()
    _str = ''.join(_list)
    _encode = hashlib.sha1(_str.encode('utf-8'))
    _encode = _encode.hexdigest()
    if _encode == request.args.get("signature"):
        return request.args.get("echostr")
    else:
        return ""
    pass

 

转载请注明:【python flask 微信公众号验证】https://jihuo.ma/wechat-mp-auth.html

评论


Andy

这个该怎么用呢


@楼主 昵称
评论