<br><br><div><span class="gmail_quote">On 1/8/08, <b class="gmail_sendername">Daniel Martin Yerga</b> &lt;<a href="mailto:dyerga@gmail.com">dyerga@gmail.com</a>&gt; 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>&quot;Jayesh Salvi&quot; &lt;<a href="mailto:jayesh@altfrequency.com">jayesh@altfrequency.com</a>&gt; wrote:<br><br>&gt; Thanks. maemo-wordpy looks like a great software. Maybe I should make
<br>&gt; 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&#39;t
<br>hesitate to do it.</blockquote><div><br>Hey Daniel,<br>
<br>
I looked at the maemo-wordpy source code.&nbsp; 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>
&nbsp; from xml.etree import ElementTree # for Python 2.5 users<br>
except:<br>
&nbsp; from elementtree import ElementTree<br>
<br>
from gdata import service<br>
import gdata<br>
import atom<br>
<br>
class Blogger:<br>
<br>
&nbsp; def __init__(self, email, password):<br>
&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;Creates a GDataService and provides ClientLogin auth details to it.<br>
&nbsp;&nbsp;&nbsp; The email and password are required arguments for ClientLogin.&nbsp; The<br>
&nbsp;&nbsp;&nbsp; &#39;source&#39; defined below is an arbitrary string, but should be used to<br>
&nbsp;&nbsp;&nbsp; reference your name or the name of your organization, the app name and<br>
&nbsp;&nbsp;&nbsp; version, with &#39;-&#39; between each of the three values.&quot;&quot;&quot;<br>
<br>
&nbsp;&nbsp;&nbsp; # Authenticate using ClientLogin.<br>
&nbsp;&nbsp;&nbsp; self.service = service.GDataService(email, password)<br>
&nbsp;&nbsp;&nbsp; self.service.source = &#39;Blogger_Python_Sample-1.0&#39;<br>
&nbsp;&nbsp;&nbsp; self.service.service = &#39;blogger&#39;<br>
&nbsp;&nbsp;&nbsp; self.service.server = &#39;<a href="http://www.blogger.com">www.blogger.com</a>&#39;<br>
&nbsp;&nbsp;&nbsp; self.service.ProgrammaticLogin()<br>
<br>
&nbsp;&nbsp;&nbsp; # Get the blog ID for the first blog.<br>
&nbsp;&nbsp;&nbsp; feed = self.service.Get(&#39;/feeds/default/blogs&#39;)<br>
&nbsp;&nbsp;&nbsp; self_link = feed.entry[0].GetSelfLink()<br>
&nbsp;&nbsp;&nbsp; if self_link:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.blog_id = self_link.href.split(&#39;/&#39;)[-1]<br>
<br>
&nbsp; def CreatePost(self, title, content, author_name, is_draft):<br>
&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;This method creates a new post on a blog.&nbsp; The new post can be stored as<br>
&nbsp;&nbsp;&nbsp; a draft or published based on the value of the is_draft parameter.&nbsp; The<br>
&nbsp;&nbsp;&nbsp; method creates an GDataEntry for the new post using the title, content,<br>
&nbsp;&nbsp;&nbsp; author_name and is_draft parameters.&nbsp; With is_draft, True saves the post as<br>
&nbsp;&nbsp;&nbsp; a draft, while False publishes the post.&nbsp; Then it uses the given<br>
&nbsp;&nbsp;&nbsp; GDataService to insert the new post.&nbsp; If the insertion is successful, the<br>
&nbsp;&nbsp;&nbsp; added post (GDataEntry) will be returned.<br>
&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;<br>
<br>
&nbsp;&nbsp;&nbsp; # Create the entry to insert.<br>
&nbsp;&nbsp;&nbsp; entry = gdata.GDataEntry()<br>
&nbsp;&nbsp;&nbsp; entry.author.append(atom.Author(atom.Name(text=author_name)))<br>
&nbsp;&nbsp;&nbsp; entry.title = atom.Title(title_type=&#39;xhtml&#39;, text=title)<br>
&nbsp;&nbsp;&nbsp; entry.content = atom.Content(content_type=&#39;html&#39;, text=content)<br>
&nbsp;&nbsp;&nbsp; if is_draft:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; control = atom.Control()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; control.draft = atom.Draft(text=&#39;yes&#39;)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry.control = control<br>
<br>
&nbsp;&nbsp;&nbsp; # Ask the service to insert the new entry.<br>
&nbsp;&nbsp;&nbsp; return self.service.Post(entry, <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;/feeds/&#39; + self.blog_id + &#39;/posts/default&#39;)<br>
<br>
if __name__ == &#39;__main__&#39;:<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; blogger = Blogger(username,password)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; content = &#39;Here goes the blog&#39;s content&#39;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title = &#39;Title&#39;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; post = blogger.CreatePost(title,content,username,is_draft=False)<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if post:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print&nbsp; 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>&nbsp;</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&#39;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