先安裝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"? # 請按照公眾平臺官網(wǎng)\基本配置中信息填寫
? ? try:
? ? ? ? check_signature(token, signature, timestamp, nonce)
? ? except InvalidSignatureException:
? ? ? ? echostr = ""
? ? return HttpResponse(echostr)