Tuesday, January 04, 2005

PyBlogger on Series 60

One of the things I've been wanting to do for a while was post directly to my blog from my Nokia 6600. With the arrival of Python for Series 60 this looked like it was going to be fairly easy to manage. The Blogger API is fairly trivial, but before reimplementing the wheel I thought I'd better look around and see if anyone had got there first with code that could be simply ported to the Series 60.

Mark Pilgrim's PyBlogger wrapper, which is now being maintained by Brent Loertscher, looked to be the thing to try and get working. In the end this proved to be pretty easy...

PyBlogger sits ontop of the XML-RPC Python Library (xmllibrpc.py) which isn't included with the Series 60 distribution. I downloaded this and pushed it onto my phone using Bluetooth, installing it as a library using the Python Installer along with the lower level xmllib.py which I grabbed from my laptop's Python 2.3 installation.

I then installed Mark's blogger.py library in a similar fashion, and fired up the bluetooth console on my Mac,
>>> import blogger
>>> username = "USERNAME"
>>> password = "PASSWORD"
>>> blogs = blogger.listBlogs(username, password)
>>> myBlog = blogs[0]
>>> print myBlog["url"]
http://www.babilim.co.uk/blog/
>>>
Worked flawlessly. Can't really complain at that point. So I think my first project, just to get me used to the UI coding issues on the phone, will be a nice little app to let me blog directly from my phone. This is so much easier than Java ME...

2 comments:

  1. Anonymous4:48 pm

    This is really cool! It is neat to see that PyBlogger can be put to such a great use.

    Brent

    ReplyDelete
  2. Anonymous11:39 pm

    Thanks for this - I just did a trivial LiveJournal client this way (beamed xmlrpclib.py and xmllib.py over from a Mac, accepted them with "install as library", beamed over a short chunk of code with hard coded values, ran it from the menu, and it posted to a test journal.) "Just Works", even using HMAC/MD5 based auth (since md5.py is already on the phone.) It would have been further down my list, but when I saw the lj xmlrpc pages, a light went on, "wait, didn't I see an article about..." :-) _Mark_ http://www.thok.org/bloggery/

    ReplyDelete