<br><br><div><span class="gmail_quote">On 1/8/08, <b class="gmail_sendername">Daniel Martin Yerga</b> <<a href="mailto:dyerga@gmail.com">dyerga@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
-----BEGIN PGP SIGNED MESSAGE-----<br>Hash: SHA1<br><br>On Mon, 7 Jan 2008 22:26:26 -0800<br>"Jayesh Salvi" <<a href="mailto:jayesh@altfrequency.com">jayesh@altfrequency.com</a>> wrote:<br><br>> Thanks. maemo-wordpy looks like a great software. Maybe I should make
<br>> a patch for it to add <a href="http://blogger.com">blogger.com</a> backend.<br><br>Thanks.<br><br>I had thought to add support for other blogging systems, among them<br><a href="http://blogger.com">blogger.com</a>
, in future versions. But if you can do a patch for blogger<br>it will be welcome, of course.<br><br>In the SVN is the most updated version it still has some bugs. It<br>has only few comments, so if you have some question you don't
<br>hesitate to do it.</blockquote><div><br>Hey Daniel,<br>
<br>
I looked at the maemo-wordpy source code. It is pretty big for me to
go through and patch. Comparatively the <a href="http://blogger.com">blogger.com</a> specific code is
extremely tiny. <br>
<br>
In fact I will paste in this email the source code that will get it
working. It is so small, because the GData library is packaged
separately. I have created the .deb installable for it and you can find
it <a href="http://www.altcanvas.com/packages/gdata-python_1.0.10.1.deb">here</a><br>
<br>
Assuming that above library is installed all you need is following class definition:<br>
<br>
try:<br>
from xml.etree import ElementTree # for Python 2.5 users<br>
except:<br>
from elementtree import ElementTree<br>
<br>
from gdata import service<br>
import gdata<br>
import atom<br>
<br>
class Blogger:<br>
<br>
def __init__(self, email, password):<br>
"""Creates a GDataService and provides ClientLogin auth details to it.<br>
The email and password are required arguments for ClientLogin. The<br>
'source' defined below is an arbitrary string, but should be used to<br>
reference your name or the name of your organization, the app name and<br>
version, with '-' between each of the three values."""<br>
<br>
# Authenticate using ClientLogin.<br>
self.service = service.GDataService(email, password)<br>
self.service.source = 'Blogger_Python_Sample-1.0'<br>
self.service.service = 'blogger'<br>
self.service.server = '<a href="http://www.blogger.com">www.blogger.com</a>'<br>
self.service.ProgrammaticLogin()<br>
<br>
# Get the blog ID for the first blog.<br>
feed = self.service.Get('/feeds/default/blogs')<br>
self_link = feed.entry[0].GetSelfLink()<br>
if self_link:<br>
self.blog_id = self_link.href.split('/')[-1]<br>
<br>
def CreatePost(self, title, content, author_name, is_draft):<br>
"""This method creates a new post on a blog. The new post can be stored as<br>
a draft or published based on the value of the is_draft parameter. The<br>
method creates an GDataEntry for the new post using the title, content,<br>
author_name and is_draft parameters. With is_draft, True saves the post as<br>
a draft, while False publishes the post. Then it uses the given<br>
GDataService to insert the new post. If the insertion is successful, the<br>
added post (GDataEntry) will be returned.<br>
"""<br>
<br>
# Create the entry to insert.<br>
entry = gdata.GDataEntry()<br>
entry.author.append(atom.Author(atom.Name(text=author_name)))<br>
entry.title = atom.Title(title_type='xhtml', text=title)<br>
entry.content = atom.Content(content_type='html', text=content)<br>
if is_draft:<br>
control = atom.Control()<br>
control.draft = atom.Draft(text='yes')<br>
entry.control = control<br>
<br>
# Ask the service to insert the new entry.<br>
return self.service.Post(entry, <br>
'/feeds/' + self.blog_id + '/posts/default')<br>
<br>
if __name__ == '__main__':<br>
blogger = Blogger(username,password)<br>
content = 'Here goes the blog's content'<br>
title = 'Title'<br>
post = blogger.CreatePost(title,content,username,is_draft=False)<br>
<br>
if post:<br>
print post.title.text<br>
<br>=====================<br><br>The above example will just post on blog. If you want to do other things like list all posts, comments, etc., then you can take a look at this <a href="http://gdata-python-client.googlecode.com/svn/trunk/samples/blogger/BloggerExample.py">
file</a><br><br>Hope that helps. Let me know if you need any other help.<br><br>Jayesh<br> </div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The SVN version needs flickrapi, for some flickr options, but<br>commenting these lines it can work without flickrapi (except the flickr<br>part).<br>Also in chinook it needs python-gtkhtml that it's in the garage<br>
(<a href="https://garage.maemo.org/projects/python-gtkhtml2/">https://garage.maemo.org/projects/python-gtkhtml2/</a>) or in the<br>extras-devel repository.<br><br>Best Regards.<br>- --<br>Daniel Martin Yerga<br><a href="http://yerga.net">
http://yerga.net</a><br>-----BEGIN PGP SIGNATURE-----<br>Version: GnuPG v1.4.6 (GNU/Linux)<br><br>iD8DBQFHg59PcnvB1T3xmfMRAlwNAJ4hXzjLhPiOgEnJ0z2dfuKCjNgR/QCfQPfs<br>DJ1Jr0mZamtocCJnjRDZ1yo=<br>=6n8l<br>-----END PGP SIGNATURE-----
<br></blockquote></div><br><br clear="all"><br>-- <br>---<br>Jayesh