示例#1
0
class Login():

    def __init__(self):
        self.config = Config()
        self.log = Log()

    def login(self):
        self.TOKEN = ""
        self.TOKEN = self.config.get_key_value("weixin", "token")
        print self.TOKEN
        data = web.input()
        signature = data.signature
        timestamp = data.timestamp
        nonce = data.nonce
        echostr = data.echostr
        list = [self.TOKEN, timestamp,nonce]
        list.sort()
        sha1 = hashlib.sha1()
        map(sha1.update, list)
        hashcode = sha1.hexdigest()
        #sha1加密算法

        #如果是来自微信的请求,则回复echostr
        if hashcode == signature:
            return echostr
示例#2
0
 def POST(self):
     str_xml = web.data()
     xmlElement = ElementTree.fromstring(str_xml)
     contentPre = xmlElement.find("Content").text #获得用户所输入的内容
     print contentPre
     if contentPre == u'主持人':
         comperelist = re.split(',', Config().get_key_value("sharing", "compereList"))
         comperecount = len(comperelist)
         num = random.randint(0, comperecount-1)
         content = comperelist[num]
         print content
     else:
         content = contentPre
     msgType = xmlElement.find("MsgType").text
     fromUser = xmlElement.find("FromUserName").text
     toUser = xmlElement.find("ToUserName").text
     return self.render.reply_text(fromUser, toUser, int(time.time()), msgType, content)
示例#3
0
class Login():
    def __init__(self):
        self.config = Config()
        self.log = Log()

    def login(self):
        self.TOKEN = ""
        self.TOKEN = self.config.get_key_value("weixin", "token")
        print self.TOKEN
        data = web.input()
        signature = data.signature
        timestamp = data.timestamp
        nonce = data.nonce
        echostr = data.echostr
        list = [self.TOKEN, timestamp, nonce]
        list.sort()
        sha1 = hashlib.sha1()
        map(sha1.update, list)
        hashcode = sha1.hexdigest()
        #sha1加密算法

        #如果是来自微信的请求,则回复echostr
        if hashcode == signature:
            return echostr
示例#4
0
 def __init__(self):
     self.config = Config()
     self.log = Log()
示例#5
0
 def __init__(self):
     self.config = Config()
     self.log = Log()