Learn More

Friday, February 10, 2012

Basic Blogger JSON Feed Api

blogger logo
We have discussed before about how to read blogger xml feed using JavaScript. That way is not always work on several browsers, especially Internet Explorer. It must someone that expert to make it works on all browsers. Fortunately, JSON feed is available by blogger, this feed is more easy than before. Although when this post is published for the first time, JSON feed is readable only. Actually, JSON feed is an xml feed that has changed to JSON format. Because data feed of blogger is an xml. To get this JSON feed you just add parameter “alt=json” or “alt=json-in-script” in your data feed. Watch the example below

http://www.example.com/feeds/posts/default?alt=json

or

http://www.example.com/feeds/posts/default?alt=json-in-script

The second url is more demand. Remember, this url is only show 25 posts for maximum. So if you want more, you need add parameter “max-results=NUMBER_POST”. As practice, access your blog JSON feed on your browser, so that it will look like follow
Code
From the code above, we can take several conclusions

ObjectDescriptionExample
json.feed.id.$tShow blog IDtag:blogger.com,1999:blog-85047
json.feed.updated.$tLast update of a blog2012-02-08T18:21:57.051+07:00
json.feed.category[]Categories / label array of a blog
json.feed.category[i].termShow the i-th categoryBlogger and widget
json.feed.title.$tShow blog nameThreelas
json.feed.subtitle.$tShow description of a blogThreelas is a good site in the world
json.feed.author[]Array of blog authorsPutri Arisnawati, Ibnu Syuhada
json.feed.author[i].name.$tShow the i-th blog author namePutri Arisnawati
json.feed.author[i].uri.$tShow the i-th profile author urihttps://profiles.google.com/116848xxx
json.feed.openSearch$totalResults.$tShow total posts222
json.feed.entry[]Posts array of a blog
json.feed.entry[i].id.$tShow the i-th post IDtag:blogger.com,1999:blog-8508.post-578455349
json.feed.entry[i].title.$tShow the i-th post titleBasic Blogger JSON Feed API
json.feed.entry[i].published.$tShow time published of the i-th post2012-02-07T12:56:00.000+07:00
json.feed.entry[i].updated.$tShow when the i-th post is updated2012-02-07T12:56:47.089+07:00
json.feed.entry[i].category[]Show array of post categories
json.feed.entry[i].category[j].termShow the j-th category of the i-th postBlogger Api
json.feed.entry[i].content.$tShow post contentThis post is explain about using JSON feed ...
json.feed.entry[i].link[]Links array of a post
json.feed.entry[i].link[j].hrefShow the j-th link of the i-th posthttp://www.example.com/2012/02/does.html
json.feed.entry[i].author[]Array of post authors
json.feed.entry[i].author[j].name.$tName of the j-th authro on the i-th postPutri Arisnawati
json.feed.entry[i].author[j].uri.$tShow uri author profilehttps://profiles.google.com/116848xxx
json.feed.entry[i].author[j].gd$image.srcImage uri of the j-th author profile on the i-th post//lh4.googleusercontent.com/photo.jpg
json.feed.entry[i].media$thumbnail.urlShow image on the i-th posthttp://3.bp.blogspot.com/Allen+Mills.jpg
json.feed.entry[i].thr$total.$tShow total threaded comments5



Retrieve a list of posts

To do this, you must read our previous post. That is only link tag with attribute “rel=alternate” will show the right url of your post. So, stat your code with the following code



Next step, choose what parameters you want to retrieve. See the example below

 

To see the result, you must use callback function. See complete code below

 

Easy, isn’t it? Each free widget from us is always using JSON feed. Now, you start making a widget.