https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Getting_Started_Guide.html
@app.get("/")
def verify(signature,timestamp,nonce,echostr):
print(signature,timestamp,',',nonce,',',echostr)
signature = signature.strip()
timestamp = timestamp.strip()
nonce = nonce.strip()
echostr = echostr.strip()
token = 'zhangboyi'
li = [token, timestamp, nonce]
li.sort()
sha1 = hashlib.sha1()
list(map(sha1.update, [x.encode('utf-8') for x in li]))
hashcode = sha1.hexdigest()
print("handle/GET func: hashcode, signature: ", hashcode, signature)
if hashcode == signature:
return echostr
else:
return ''
代码更换之后,能够成功返回enchostr的信息,但是却还是提示token验证失败