微信公众平台服务器配置token验证

@app.route('/')
def index():
    signature = request.args.get("signature")
    timestamp = request.args.get("timestamp")
    nonce = request.args.get("nonce")
    echostr = request.args.get("echostr")
    token = "设置的token"

    list = [token, timestamp, nonce]
    list.sort()
    sha1 = hashlib.sha1()
    map(sha1.update, list)
    hashcode = sha1.hexdigest()
    print "handle/GET func: hashcode, signature: ", hashcode, signature
    if hashcode == signature:
        return echostr
    return "ok"

微信官方文档:https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Getting_Started_Guide.html

保证填写的服务器地址(URL) 80端口转到此路径下即可

posted @ 2020-02-14 21:03  待炒的鱼  阅读(705)  评论(0编辑  收藏  举报