1. 配置wexin, 開啓tornado 服務器linux
code ser:服務器
WECHAT_TOKEN = "hyhlinux"微信
class WeChatHandler(RequestHandler):tornado
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') code
tmp = [WECHAT_TOKEN, timestamp, nonce]
tmp.sort()
tmp_str = "".join(tmp)
tmp_str = hashlib.sha1(tmp_str).hexdigest()get
if (tmp_str == signature):
print('wechat 200')
self.write(echostr)
else:
# 403 倍禁止
print('wechat 403')
self.send_err(403)hash
點擊提交後:it
ser: 成功被調用,同時sigclass
weixin:配置
2.