Wednesday, May 4, 2011

Google Blogger OAuth API

After getting Oauth token and secret from Google for blogger
Check out this "playground" http://googlecodesamples.com/oauth_playground/index.php
it's so hard to even find the details of how to register your app with Google, what
url to use to request Oauth Token for blogger API.

When I find it again (takes a lot of wasted time to just find the correct url for documentation as Google scattered the blogger API documentation all over their sites - some in Oauth data related pages, some on Blogger API related pages...)

Some piece meal bits of data for Google OAuth API developers:



You will need to register your domain with Google. This included downloading some lame html file from Google then uploading it to root dir of your site and then clicking "verify" button, basically proving to Google that you are the admin of that domain.

Once that is done you need to go here https://www.google.com/accounts/UpdateDomain
and enter some string that you must create yourself - some type of long secret string, into the
"Target URL path prefix"
That will become your app's OAuth Consumer Key and Google will generate the OAuth Consumer Secret value for you. This is the lamest and most unintuitive way I"ve seen in any APIs to get your OAuth Consumer API key and OAuth consumer secret. But that's how it is with Google, it's because they don't really care about the developers(about schmucks like you)

Now you will probably be able to use OAuth protocol, but of cause nothing is "easy" when it comes to Google's implementation of OAuth - remember this kids - Google does not care about developers and does not want to provide clear and easy-to-understand or even easy-to-find documentation.



Some details are here
http://code.google.com/apis/blogger/docs/2.0/developers_guide_protocol.html

can use this url to get list of user's blogs: https://www.blogger.com/feeds/default/blogs

It will be in the superbly fucked-up format written by incompetent fools at Google.
Even though it's in XML format, there is no entry for "blogID" and you must extract it from the tag using regex.

The url for the POST - to post your entry to blogger using api is also not easy to extract. It's buried in the
Why the fuck the type="html"? This is an XML file - supposed to be pure data, why html?
That's not even the worst part.

To extra the url for post you need to find an entry in the "summary" tag that looks like this:


There is no easy way to extract this entry because there are a bunch of other very similar entries. Your only clue to use is that the "rel" attribute must end with #post How do you extract this entry? Is there a way to use XPATH when the only condition you have is that value of an attribute ends with #post?
Maybe if you can be certain that value will be "http://schemas.google.com/g/2005#post" then yes, it's possible to find this entry easily and then use the value of href

But it's probably easier to just extract and store the blog-id by extracting it out of the tag.



No comments:

Post a Comment