问题已经解决!将 sha1 = hashlib.sha1() map(sha1.update, list) hashcode = sha1.hexdigest() 替换成 hashcode = hashlib.sha1("".join(list).encode('utf8')).hexdigest()
服务器配置Token验证失败web.py(已解决)?[图片] url没错 Token没错 后台也有日志输出,直接返回echostr 公网可以访问,python写的后台 handle.py # -*- coding: utf-8 -*- # filename: handle.py import hashlib import web class Handle(object): def GET(self): try: data = web.input() print(data) if len(data) == 0: return "hello, this is handle view" signature = data.signature timestamp = data.timestamp nonce = data.nonce echostr = data.echostr token = "shaiden109" #请按照公众平台官网\基本配置中信息填写 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 else: return "" except Exception as e: print(e) return e 曾经做过公众号,都是因为token这个问题没做完,这个服务器已经加入白名单了。
2023-03-07