Ejemplo n.º 1
0
 def get(self):
     code=self.get_argument('code')
     client=APIClient(app_key=APP_KEY,app_secret=APP_SECRET,redirect_uri=CALLBACK_URL)
     r=client.request_access_token(code)
     access_token=r.access_token
     expires_in=r.expires_in
     uid=r.uid
     client.set_access_token(access_token,expires_in)
     
     userinfo=client.users__show(uid=uid)
     if userinfo:
         self.db.execute("INSERT INTO users(uid,username,province,city,location,gender,profile_image_url,verified,followers_count,friends_count,avatar_large,verified_reason,bi_followers_count) VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",
                         userinfo['id'],userinfo['screen_name'],userinfo['province'],userinfo['city'],userinfo['location'],userinfo['gender'],userinfo['profile_image_url'],userinfo['verified'],userinfo['followers_count'],userinfo['friends_count'],userinfo['avatar_large'],userinfo['verified_reason'],userinfo['bi_followers_count'])
     else:
         return
      
     self.render("home.html")
Ejemplo n.º 2
0
 def get(self):
     client=APIClient(app_key=APP_KEY,app_secret=APP_SECRET,redirect_uri=CALLBACK_URL)
     url=client.get_authorize_url()
     self.redirect(url)