Saturday 18 June 2011

How to fix your broken Blogger client program

For about a month now I and other people have been unable to use the blogger api to update our blogs. This is one of a raft of problems caused by a recent update of the blogger system, and some other ones (including the fact my OpenID is broken) are still outstanding. However, the OpenID thing isn't a big deal, whereas the api blog posting is something I use a lot.

I can happily report that the Blogger/Google people have come through for us and found the problem. I had been losing hope, because as a linux user I'm used to having people break stuff, and then say the problem is that I'm running linux. But, though it's admittedly taken them a while, google's blogger team have dug to the bottom of the problem and found the cause. Maybe I should have more faith in future, we'll see.

If you've found that your blogger API client program has stopped working in the last month, then what follows is what you need to do to get it working again.



Turns out that some of us had misinterpreted the blogs 'posting endpoint' to be this

http://idratherhack.blogspot.com/feeds/posts/default

which was working fine, you could send the appropriate XML to this endpoint, and post to your blog. But it was never supposed to work, and since the upgrade, it doesn't. This is a shame, because it's a nice URL that makes some sense to the user.

The endpoint we should have been using looks more like:

http://www.blogger.com/feeds/8441087078477003568/posts/default

So the question is, how do you get from a blog name/url like 'idratherhack.blogspot.com' to this horrible blog ID? Well, there's a few ways of doing it.

1) Connect to your blog and pull it as an html page. Near the top you'll see an entry like:

<link rel="service.post" type="application/atom+xml" title="I&#39;d Rather Hack - Atom" href="http://www.blogger.com/feeds/8441087078477003568/posts/default" />
The 'href' part of this gives you the url that you should use for posting to the blog.

2) The more complex way is described in the protocol document


1: Authenticate with google using client-login or Oauth.

2: do an HTTP GET to http://www.blogger.com/feeds/default/blogs

This will return a mass of XML that gives information regarding the authenticated user. Within this are entries like:


<link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/profileID/blogs/blogID' />
<link rel='alternate' type='text/html' href='http://blogName.blogspot.com/' />
<link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blogName.blogspot.com/feeds/posts/default' />
<link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='http://www.blogger.com/feeds/blogID/posts/default' />



The important one is the one that has a 'rel' value of

http://schemas.google.com/g/2005#post

the accompanying 'href' gives the endpoint you must used for posting blog entries. Here it is described as 'http://www.blogger.com/feeds/blogID/posts/default', but when you get a real feed the 'blogID' will be replaced by a big old number to produce a unique endpoint for the blog.

This XML also contains other interesting 'link' entries, like:

rel=http://schemas.google.com/blogger/2008#setting
rel=http://schemas.google.com/blogger/2008#template

the href of these gives endpoints that let you pull a list of settings or the template of the blog.


So basically, if you get this 'post' endpoint, and use that instead of http://<blogname>.blogspot.com/feeds/posts/default, you should find that your API program starts working again.

4 comments:

  1. Oh no. I was already doing this, and I still can't post.

    ReplyDelete
  2. I'm not sure Onus, but the problem you described elsehwere (getting a 200 rather than a 201 response) rings a bell with me. I think that the '200' might return some error withing the returning page.

    Basically it's saying "Things were alright at the http level, but at the blogger level there was a problem, and here is some xml to explain it".

    Did you get anything back from the 200 response?

    ReplyDelete
  3. Halo semuanya
    Saya ingin menggunakan media ini untuk membuat Anda semua tahu bahwa mendapatkan pinjaman tidak sesulit dan sesulit yang Anda kira

    Saya Rina Mariana penduduk asli bandung. Indonesia
    Saya mendapat pinjaman dari  ONE BILLION RISING FUND dan proses aplikasi saya mudah, lancar dan mudah dimengerti dan saya telah diberkati sejak saya baru menjadi firma pinjaman dan hidup saya tidak lagi menjadi bahan tertawaan bagi orang-orang, tetapi mereka datang kepada saya sekarang untuk meminta nasihat dan bagaimana membantu mereka secara finansial dan sejauh ini saya telah memperkenalkan cukup banyak orang kepada perusahaan pinjaman dan mereka juga mendapatkan pinjaman dari   ONE BILLION RISING FUND

    Saya akan menyarankan bahwa jika Anda membutuhkan pinjaman dan Anda ingin mendapatkan bantuan karena kami telah mendapatkan bantuan dari  ONE BILLION RISING FUND   kemudian hubungi perusahaan pinjaman melalui gmail di bawah ini dan dapatkan transformasi dalam hidup Anda secara finansial seperti yang kami lakukan
    Mereka yakin, aman, andal, dan terbuka untuk pelanggan
    Mengapa saya menyukai mereka adalah Anda sangat bebas untuk bertanya tentang pinjaman Anda dan layanan mereka 24/7

                                              KONTAK PERUSAHAAN

     Nama Perusahaan ::::::ONE BILLION RISING FUND
    Gmail: onebillionrisingfund@gmail.com

                                 Hubungi saya
    Rina Marian
    rinamariana874@gmail.com

    ReplyDelete