Charl van Niekerk » Blog

Main

Latest

Archives

Powered by Blogger

Twitter on Google App Engine

I tried to post a message to Twitter from Google App Engine and just gave up. Normally I am a die-hard hacker that does not give up easily, but sometimes a man needs to know when he is truly pwned.

Here is the code, which works fine with dev_appserver.py:

url = 'http://twitter.com/statuses/update.xml'
payload = urllib.urlencode({'status': 'my update message'})
basicauth = base64.encodestring('%s:%s' % ('myusername', 'mypassword'))[:-1]
headers = {'Authorization': 'Basic %s' % basicauth}
urlfetch.fetch(url=url, payload=payload, method=urlfetch.POST, headers=headers)

However, after being uploaded, Twitter keeps returning the following error:

403 Forbidden: The server understood the request, but is refusing to fulfill it. If you are posting from an API tool please ensure that the HTTP_REFERER header is not set.

Yes, Google forces the HTTP_REFERER and Twitter will have none of it. And yes, this has been raised on Twitter Development Talk list by myself and others. We are waiting for some (re)action.

1 Comments

Comment by Blogger Barry V. on Monday, November 24, 2008 12:37:00 AM

Just seeing if you ever resolved this. I used your code example to try it on GAE (http://tapingya.com) with success. Things have changed since this post I'm sure, but wanted to give you a heads up in case you still cared. :)

Post a Comment

Copyright © 2004-2009 Charl van Niekerk. All articles are released under the Creative Commons Attribution 2.5 South Africa licence, unless where otherwise stated.