张子强下跪给向华强,pinsetangmianfei,巴西双头婴儿
情景:配置如下截图:
按照要求使用http标准80端口,但是提交就报错。在服务端抓包,根本没收到请求。那这个报错就是微信公众平台没有发送过来呀。
折腾了半个小时!
我去,发现不能在url中指定80端口,就可以成功,如下图:
这样不指定端口才正确。微信说明还是不是很明确
# -*- coding: utf-8 -*- # filename: handle.py import hashlib import web class Handle(object): def GET(self): try: data = web.input() if len(data) == 0: return "hello, this is handle view" signature = data.signature timestamp = data.timestamp nonce = data.nonce echostr = data.echostr token = "xxxx" #请按照公众平台官网\基本配置中信息填写 list = [token, timestamp, nonce] list.sort() sha1 = hashlib.sha1() map(sha1.update, list) # 这里list中的字符串在py2中是符合sha1.update要求的 hashcode = sha1.hexdigest() print "handle/GET func: hashcode, signature: ", hashcode, signature if hashcode == signature: return echostr else: return "" except Exception, Argument: return Argument
""" handle.py """ import hashlib import web class Handle(object): def GET(self): try: data = web.input() if len(data) == 0: return "hello, this is handle view" signature = data.signature timestamp = data.timestamp nonce = data.nonce echostr = data.echostr token = "****" # 自己定义的tokent list = [token, timestamp, nonce] list.sort() sha1 = hashlib.sha1() sha1.update(''.join(list).encode('utf-8')) # 将py3中的字符串编码为bytes类型 hashcode = sha1.hexdigest() print("handle/GET func: hashcode, signature:", hashcode, signature) if hashcode == signature: return echostr else: return "" except Exception as e: print(e) if __name__ == '__main__': pass
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Python 实现将numpy中的nan和inf,nan替换成对应的均值
python爬虫把url链接编码成gbk2312格式过程解析
网友评论