公众号开发服务器配置一直提示token验证失败?
服务器地址:http://106.55.23.112/
appid:wx8f7ca7889b24911e
请求验证身份信息:
返回的echostr:
服务器配置失败,
服务器的日志消息显示已经微信的get请求已经进入并成功返回了 “echostr”的值
但是依然显示token配置失败。
2 回复
from fastapi import FastAPI
import hashlib
app = FastAPI()
@app.get("/hello")
def hello():
return "hello"
@app.get("/verify")
def verify(signature,timestamp,nonce,echostr):
print(signature,timestamp,',',nonce,',',echostr)
token = 'zhangboyi'
li = [token, timestamp, nonce]
li.sort()
sha1 = hashlib.sha1()
# list(map(sha1.update, [x.encode('utf-8') for x in li]))
sha1.update(li[0].encode('utf-8'))
sha1.update(li[1].encode('utf-8'))
sha1.update(li[2].encode('utf-8'))
hashcode = sha1.hexdigest()
print("handle/GET func: hashcode, signature: ", hashcode, signature)
if hashcode == signature:
return echostr.encode('utf-8')
else:
return ''
import uvicorn
if __name__ == '__main__':
uvicorn.run(app,host='0.0.0.0')