def post(self, site): if site == "wb": content = self.get_argument("content") access_token = self.session.get("oauth_access_token") auth = OAuthHandler(options.SINA_APP_KEY, options.SINA_APP_SECRET) auth.set_access_token(access_token.key, access_token.secret) api = API(auth) api.update_status(content) self.finish(json.dumps("success"))
def __init__(self, *argc, **argkw): super(BaseHandler, self).__init__(*argc, **argkw) self.path = '' self.session = session.TornadoSession(self.application.session_manager, self) if self.session.get('platform') == 'weibo': self.sina_access_token = self.session.get('oauth_access_token') auth = OAuthHandler(options.SINA_APP_KEY, options.SINA_APP_SECRET) auth.set_access_token(self.sina_access_token.key, self.sina_access_token.secret) self.sina_api = API(auth) elif self.session.get('platform') == 'renren': self._userid = int(self.get_user_id()) print "renren ok" elif self.session.get('platform') == 'douban': self._userid = int(self.get_user_id()) print "douban ok"