def get(self):
try:
webData = self.request.body
#print "Handle Get webdata is ", webData
log.debug("Handle Get webdata is %s" % (webData))
signature = self.get_argument('signature', '')
timestamp = self.get_argument('timestamp', '')
nonce = self.get_argument('nonce', '')
echostr = self.get_argument('echostr', '')
token = test_weixin_token
if len(signature) == 0 or len(timestamp) == 0 or \
len(nonce) == 0 or len(echostr) == 0:
self.write('')
list = [token, timestamp, nonce]
list.sort()
sha1 = hashlib.sha1()
map(sha1.update, list)
hashcode = sha1.hexdigest()
#print "handle/GET func: hashcode, signature: ", hashcode, signature
log.debug("handle/GET func: hashcode, signature: %s, %s"%(hashcode, signature))
if hashcode == signature:
self.write(echostr)
else:
self.write('')
except Exception, Argument:
log.error(Argument)
self.write(Argument)
评论列表
文章目录