def on_get(self, request, response):
# Get the parameters from the query string
signature = request.get_param('signature')
timestamp = request.get_param('timestamp')
nonce = request.get_param('nonce')
echostr = request.get_param('echostr')
# Compute the signature (note that the shared token is used too)
verification_elements = [self.token, timestamp, nonce]
verification_elements.sort()
verification_string = "".join(verification_elements)
verification_string = hashlib.sha1(verification_string.encode('utf-8')).hexdigest()
# If the signature is correct, output the same "echostr" provided by the WeChat server as a parameter
if signature == verification_string:
response.status = falcon.HTTP_200
response.body = echostr
else:
response.status = falcon.HTTP_500
response.body = ""
# Messages will be POSTed from the WeChat server to the chatbot backend server,
# see: http://admin.wechat.com/wiki/index.php?title=Common_Messages
wechatapiresource.py 文件源码
python
阅读 20
收藏 0
点赞 0
评论 0
评论列表
文章目录