Пример #1
0
    def on_response(self, response):
        access_token = ""
        openid = ""
        if response.code == 200:
            try:
                resp_dict = json.loads(response.body)
                access_token = resp_dict["access_token"]
                openid = resp_dict["openid"]

            except Exception as e:
                logs_general.warning(str(e))
                self.write("failure")
            	self.finish()
                return

            data = urllib.urlencode(dict(
                                         access_token=access_token,
                                         openid=openid,
                                         lang="zh_CN"
                                             ))
            url = "https://api.weixin.qq.com/sns/userinfo?" + data

            httpClient = tornado.httpclient.AsyncHTTPClient()
            request = tornado.httpclient.HTTPRequest(url=url)
            httpClient.fetch(request, self.get_userinfo)
Пример #2
0
 def get_userinfo(self, response):
     if response.code == 200:
         try:
             resp_dict = json.loads(response.body)
         	self.render("userinfo.html", **resp_dict)
         except Exception as e:
             logs_general.warning(str(e))
             self.write("failure")
         	self.finish()
             return
     else:
         self.write("failure")
         self.finish()