Example #1
0
 def get(self):
     #Got redirecte from douban.
     #fetch access token
     token = self.request.get('oauth_token', '')
     if token:
         do = douban_oauth.douban()
         du = Doubaner.all().filter('oauth_token =', token).get()
         
         do.oauth_token = du.oauth_token
         do.oauth_token_secret = du.oauth_token_secret
         
         at = do.fetch_access_token()
         
         token = at['oauth_token']
         secret = at['oauth_token_secret']
         uid = at['douban_user_id']
         
         du.uid = uid
         du.oauth_token = token
         du.oauth_token_secret = secret
         du.slug = new_urn(uid)
         du.put()
     
         
         self.response.headers['Content-Type'] = 'text/html'
         base_url = self.request.url[:self.request.url.find(self.request.path)]
         self.response.out.write('You can now point your ping.fm customized URL to:\t%s' % base_url+'/pingfm/'+du.slug+'<br />')
     else:
         NotFoundPageHandler.get(self)
Example #2
0
 def get(self):
     do = douban_oauth.douban()
         
     base_url = self.request.url[:self.request.url.find(self.request.path)]
     url = do.build_auth_url(base_url+'/finish')
     n = Doubaner(oauth_token=do.oauth_token, oauth_token_secret=do.oauth_token_secret)
     n.put()
     
     self.redirect(url)
Example #3
0
    def post(self, slug):
        #TODO: token expired?
        method = self.request.get('method', '')
        title = self.request.get('title', '')
        message = self.request.get('message', '')
        r = Doubaner.all().filter('slug =', slug).get()
        do = douban_oauth.douban(r.oauth_token, r.oauth_token_secret)
        c = '<?xml version="1.0" encoding="UTF-8"?>\
<entry xmlns:ns0="http://www.w3.org/2005/Atom" xmlns:db="http://www.douban.com/xmlns/">\
<content>%s</content></entry>' % estutil.xml_escape(message)
        logging.info(r.uid+' '+message)
        do.q('http://api.douban.com/miniblog/saying', c, { 'Content-Type': 'application/atom+xml' })
        self.response.out.write('<br />'.join( [x+'='+self.request.get(x, '') for x in self.request.arguments()] ))
Example #4
0
 def get(self, uid='1331775'):
     r = Doubaner.all().filter('uid =', uid).get()
     do = douban_oauth.douban(r.oauth_token, r.oauth_token_secret)
     c = do.q('http://api.douban.com/people/%40me').read()
     self.response.headers['Content-Type'] = 'text/xml'
     self.response.out.write(c)