That was my experience with JSON. I'm not a web uber geek by any stretch of the imagination and have spent over two decades doing IT programming all without coding a line of html.
I am quite fine with that. But I was confronted by what seemed to be a simple exercise in configuring this website: having it return a list of posts 'by Author'.
Well, no. It turns out that there isn't a lever, toggle, switch one can pull to make that happen. Yes, a post does indeed have category tags, but to have that work reliably one must explicitly append a 'tag' to the post, i.e., the name of the Author. One omission will result in the query missing a post. That isn't acceptable.
So, I thought there must be a way to get that seemingly basic information from a post. Yes?
Yes! It turns out that Google has an array of APIs to their product line and, categorically, Blogger has its very own. It's called Javascript Object Notation or JSON for short.
This is good news. Yes?
So, I proceeded to pour over the documentation in earnest hoping that if I stared long enough and tried various API calls I could get it to cooperate.
This went on for over two weeks with my poking at it periodically without success.
Finally, I decided to try a simple test to see what Google's API would return using JSON. It is pretty basic:
Blogger API Example
When I saved the html and opened the test.html from my local share, it returned to the screen 'Undefined' 'Undefined' as if to taunt me once again. I was taunted.
So, I double-checked my settings in the Google API console, even recreated my apikey just to be sure and then took just the RESTful portion (I've obfuscated the api key as 'xxxxxxxxxxxxxxxxxx'), and ran it from a terminal command line to see what was in the response. It returned 200 OK but the response included information I had not seen up to this point, a clue to what was keeping my simple JSON query from giving over the goods:
// API callback handleResponse({ "error": { "errors": [ { "domain": "usageLimits", "reason": "dailyLimitExceededUnreg", "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.", "extendedHelp": "https://code.google.com/apis/console" } ], "code": 403, "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup." } } );
Ah hah! Now we are getting somewhere. So, in spite of my due diligence in obtaining an api key, it turns out that obtaining an api key has a very limited quota so I had spent it in my previous incantations and the message was clear in saying I should 'sign up'. So, yesterday, late in the day, I signed up and sent off the form to Google which replied that it might take as much as several days before my request would receive a review.
Late last night, an email came from a chap at Google who enabled my apikey. I was quite pleased with the quick turn-around and sent him a thank you email.
With that I dispatched directly back to firing off my test.html opening it from my local share. Much to my pleasant surprise, it dutifully responded with a response:
Just so you know: Checking with multiple browsers and the right-hand side of your post has been cut off, so parts of words or occasionally full words are lost. If you need help trouble-shooting this I would be willing to assist.
ReplyDeleteThanks for the catch. I just fixed.
ReplyDelete