博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
微信公众号开发-遇到的坑
阅读量:4709 次
发布时间:2019-06-10

本文共 2047 字,大约阅读时间需要 6 分钟。

博文图片挂了临时解决办法

o_%E6%9F%A5%E7%9C%8B%E6%8C%82%E5%9B%BE%E4%B8%B4%E6%97%B6%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95.png

在配置后端服务器时,报错 "系统发生错误,请稍后重试"

情景:配置如下截图:

1342974-20180516104020766-1507513918.png

按照要求使用http标准80端口,但是提交就报错。在服务端抓包,根本没收到请求。那这个报错就是微信公众平台没有发送过来呀。

折腾了半个小时!
我去,发现不能在url中指定80端口,就可以成功,如下图:
1342974-20180516125501863-1108963497.png
这样不指定端口才正确。微信说明还是不是很明确

在handle模块,实例代码是py2代码,py3中要进行编码转换

  • 微信开发文档的代码,在py3中执行会一直报token验证错误。
# -*- coding: utf-8 -*-# filename: handle.pyimport hashlibimport webclass 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
  • py3修改后的
"""handle.py"""import hashlibimport webclass 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

转载于:https://www.cnblogs.com/ZJiQi/p/9045413.html

你可能感兴趣的文章
Alpha 冲刺 (5/10)
查看>>
使用Siege进行WEB压力测试
查看>>
斑马为什么有条纹?
查看>>
android多层树形结构列表学习笔记
查看>>
Android_去掉EditText控件周围橙色高亮区域
查看>>
《构建之法》第一、二、十六章阅读笔记
查看>>
Git Stash用法
查看>>
Jquery radio选中
查看>>
netty接收大文件的方法
查看>>
软件工程设计之四则运算
查看>>
SpringMVC @ResponseBody 406
查看>>
Partial Tree UVALive - 7190(完全背包)
查看>>
顺序容器的insert使用方法
查看>>
Markdown的使用
查看>>
销售系统学习.mdl
查看>>
触发器
查看>>
mysql配置默认字符集为UTF8mb4
查看>>
WPF实现3D翻转的动画效果
查看>>
自定义圆环进度条
查看>>
UILayer
查看>>