Django后台验证微信公众号 token

先安装wechatpy

pip install wechatpy


def wx(request):

    signature = request.GET['signature']

    timestamp = request.GET['timestamp']

    nonce = request.GET['nonce']

    echostr = request.GET['echostr']

    token = "xxxxx"  # 请按照公众平台官网\基本配置中信息填写

    try:

        check_signature(token, signature, timestamp, nonce)

    except InvalidSignatureException:

        echostr = ""

    return HttpResponse(echostr)

你可能感兴趣的:(Django后台验证微信公众号 token)