小程序
补充:
1.服务器是阿里云的机器;
2.公众号是微信公众平台测试号;
问题原因:
官方文档(上面的参考文档)python代码有问题
解决:
另一份官方文档的说明是正确的,文档地址:https://developers.weixin.qq.com/miniprogram/dev/framework/server-ability/message-push.html
本人测试可行的代码如下:
# -*- 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(v8)"
signature = data.signature
timestamp = data.timestamp
nonce = data.nonce
echostr = data.echostr
token = "fkonsdrtmxckzoe15cyiibnwy2l6hduh"
list = [token, timestamp, nonce]
list.sort()
sorted_str = ''.join(list)
hash_obj = hashlib.sha1(sorted_str.encode('utf-8'))
calc_signature = hash_obj.hexdigest()
print("handle/GET func: calc_signature, signature: ", calc_signature, signature)
if calc_signature == signature:
return echostr
else:
return ""
except Exception as Argument:
print("Argument:", Argument)
return Argument
没错,这就是页面地址参数,#后面是锚点