1. 配置wexin, 开启tornado 服务器
code ser:
WECHAT_TOKEN = "hyhlinux"
class WeChatHandler(RequestHandler):
def get(self):
signature = self.get_argument('signature') #get发过来的,我们需要验证是微信
timestamp = self.get_argument('timestamp') #1.时间戳
nonce = self.get_argument('nonce') #
echostr = self.get_argument('echostr')
tmp = [WECHAT_TOKEN, timestamp, nonce]
tmp.sort()
tmp_str = "".join(tmp)
tmp_str = hashlib.sha1(tmp_str).hexdigest()
if (tmp_str == signature):
print('wechat 200')
self.write(echostr)
else:
# 403 倍禁止
print('wechat 403')
self.send_err(403)
点击提交后:
ser: 成功被调用,同时sig
weixin:
2.