Return to Snippet

Revision: 6033
at April 22, 2008 09:48 by sgraber


Initial Code
class SendChime(webapp.RequestHandler):
   def get(self):
      self.response.headers['Content-Type'] = 'text/plain'
      username =  self.request.get("username")

      login =  username
      password = "password"
      chime = self.get_chime()
      payload= {'status' : chime,  'source' : "innertwitter"}
      payload= urllib.urlencode(payload)

      base64string = base64.encodestring('%s:%s' % (login, password))[:-1]
      headers = {'Authorization': "Basic %s" % base64string} 

      url = "http://twitter.com/statuses/update.xml"
      result = urlfetch.fetch(url, payload=payload, method=urlfetch.POST, headers=headers)

      self.response.out.write(result.content)

   def get_chime(self):
      now = datetime.datetime.now()
      chime = "........*chime*.............." + now.ctime()
      return chime
 
def main():
  application = webapp.WSGIApplication(
                                       [('/innertwitter', InnerTwitter),
                                       ('/sendchime', SendChime)],
                                       debug=True)

Initial URL
http://highscalability.com/using-google-appengine-little-micro-scalability

Initial Description
A way to post to twitter from Google AppEngine using urlfetch.

Initial Title
Posting to Twitter from Google AppEngine

Initial Tags
python

Initial Language
Python