Retrieving Blogger posts by post id
I spent some time recently trying to figure out, using Google’s gdata API, how to retrieve a post from a Blogger blog if I know corresponding post id. As far as I can tell there is no obvious way of doing this, at least not using the gdata.blogger.client api, but after much nashing of teeth I came up with the following solution.
Given client, a gdata.blogger.client instance, and blog, a gdata.blogger.data.Blog instance, the following code will return a gdata.blogger.data.BlogPost instance:
post = client.get_feed(blog.get_post_link().href
+ '/%s' % post_id,
auth_token=client.auth_token,
desired_class=gdata.blogger.data.BlogPost)
I’m not sure if this is the canonical solution or not, but it appears to work for me.