Friday, January 29, 2010

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.

11 comments:

  1. Nice post. I have read people's stories of how they lost their post and are looking for help in order to retrieve these.
    Thanks for the information.
    SEO Reseller
    ReplyDelete
  2. I am so glad this internet thing works and your article really helped me. Might take you up on that home advice you gave. Perhaps a guest appearance would be good.
    White Label SEO
    ReplyDelete
  3. any suggestions on this would work with the PHP api?
    ReplyDelete
  4. Thank you very much for sharing this.
    seo reseller
    ReplyDelete
  5. "I'm not sure if this is the canonical solution or not, but it appears to work for me." If it works for one, it has a big possibility to work for others. I'll try out. Thanks for this solution!

    seo norwich
    ReplyDelete
  6. Thank you for the great solution. It's not cannonical but it still works for me.

    web design
    ReplyDelete
  7. This is pretty simple but a great way to improve SEO for your Blogger.

    web hosting uk
    ReplyDelete
  8. I never thought of going this far in modifying my blog account. I know that one day this tip will come in handy so I'll bookmark it now.

    seo web hosting
    ReplyDelete
  9. This comment has been removed by the author.
    ReplyDelete
  10. This is amazing. Thanks for sharing this.

    seo london
    ReplyDelete
  11. Thank you for modifying this post. I really love modifying my blogs starting from simple tricks to more advance tips.
    You can also use free SEO tools online.
    ReplyDelete