Charl van Niekerk » Blog

Main

Latest

Archives

Powered by Blogger

Jaiku on Google App Engine

This is quite a dirty hack, but it works really well.

You can't use Python's standard xmlrpclib on Google App Engine because of the socket restrictions. The only thing I managed to get running so far is Google's special urlfetch library.

So here is the solution. And this one, unlike the Twitter one, actually works on both dev_appserver.py and after being uploaded (at least last when I tried). After all, it's all Google (Jaiku has mos been bought over and everything...)

url = 'http://api.jaiku.com/xmlrpc'
payload = "<?xml version='1.0'?><methodCall><methodName>presence.send</methodName><params><param><value><struct><member><name>personal_key</name><value><string>%s</string></value></member><member><name>message</name><value><string>%s</string></value></member><member><name>user</name><value><string>%s</string></value></member></struct></value></param></params></methodCall>" % (cgi.escape('myjaikukey'), cgi.escape('my new update'), cgi.escape('myjaikuuser'))
urlfetch.fetch(url=url, payload=payload, method=urlfetch.POST)

This should allow you to post a new message and other API calls can probably be done similarly.

Btw, how did I get this XML-RPC request you might ask? I used the standard xmlrpclib on my localhost and ran ngrep while the request was being made. :)

0 Comments

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.