The main purpose of the Bloggers Api is to create a client application. With this application you can view and update Blogger content without having to go into your blogger account. Lots of tutorials about bloggers using Blogger Api. Blogger Api works based on the Google Data Api. So we strongly recommend that you first read our topics on Basic Google Data Api.
Users can create a list of blog posts, displaying the contents of those posts, the date of posting, editing, make a post, giving access to comments, and so forth. All of that can be done using Blogger Api.
Before starting, we want you to always remember that, as long as your blog is public then you can display a list of blog posts without having to make authentic. However, if you want to edit, make a post, then you have to do authentic. The scope for authentic blogger is http://www.blogger.com/feeds/. Yes, you're asked for a feed from bloggers. But for now, we are not discuss about how to make authentic for blogger.
Retrieving a list of blog
In practice, blogger is providing a feed for retrieving a list of blog posts. This feed named as metafeed. When you want to retrieve that, you must send a HTTP GET to the following url :
GET http://www.blogger.com/feeds/profileID/blogs
If you don't know your profileID, you can find it from your view profile inside your blogger dashboard. But, if you have been joining with google+ profile, then you can't find it anymore. You must change your profile from google+ profile into blogger profile. Unfortunately, if you have switched into google+ profile more than 30 days, then you can not switch back again. So save your blogger profile immediately. After you send that url, server will response and give you a xml file like follow:
after that, you can use any programming language for read that feed (xml file). For the next time, we only provide tutorial for javascript. Remember, you don't have to make authentic as long as your blog is public.
you don't have to create <author> tag, because this tag will create automatic. To publish your content, google has been giving instruction as follow "To publish this entry, send it to the blog's post URL as follows. First, place your Atom <entry> element in the body of a new POST request, using the application/atom+xml content type. Then find the blog's post URL in the metafeed by locating the <link> element where the rel attribute ends with #post. The blog's post URL is given as the href attribute of this element, which is in this format: http://www.blogger.com/feeds/blogID/posts/default."
Actually, blogger have created this procedure automatic. Please try, view source of your page, you can do this by right click your page on window browser, then choose view source. You will see code as follow
this code is same meaning with google instruction. Meaning, this code has been create automatic by blogger.
As a practice, please create a post, but don't publish it. Then open the address http://www.blogger.com/feeds/blogID/posts/default, you will see <app:control> tag. Because at that time, you have been making a draft.
GET http://www.blogger.com/feeds/blogID/posts/default
Source: google data api
http://www.blogger.com/feeds/blogID/posts/default?alt=rss
or
Create and Publish a blog post
Before you create and publish a blog post, you must make an authentic first. Then create a xml file with contain <entry> tag. See the example belowyou don't have to create <author> tag, because this tag will create automatic. To publish your content, google has been giving instruction as follow "To publish this entry, send it to the blog's post URL as follows. First, place your Atom <entry> element in the body of a new POST request, using the application/atom+xml content type. Then find the blog's post URL in the metafeed by locating the <link> element where the rel attribute ends with #post. The blog's post URL is given as the href attribute of this element, which is in this format: http://www.blogger.com/feeds/blogID/posts/default."
Actually, blogger have created this procedure automatic. Please try, view source of your page, you can do this by right click your page on window browser, then choose view source. You will see code as follow
this code is same meaning with google instruction. Meaning, this code has been create automatic by blogger.
Creating a draft of a post
Creating a draft is same procedure with publishing a post, but it must contain <app:control> tag. See the example belowAs a practice, please create a post, but don't publish it. Then open the address http://www.blogger.com/feeds/blogID/posts/default, you will see <app:control> tag. Because at that time, you have been making a draft.
Retrieving blog posts
As what explained on the older post. You must using GET method. And followed with the following urlGET http://www.blogger.com/feeds/blogID/posts/default
Based on our post before. As long as your blog is public and just only for retrieving all blog posts, you can use another way as follow
GET http://www.example.com/feeds/posts/default
If your url requst is correct (200 message), then server (google) will send you a xml feed. From this step, you can use your programming language to read that xml feed. There are parameters for retrieving blog posts. Because, sometimes you don't have to retrieve all blog posts. May be posts with specific label or else. See the table parameters below
Parameter | Meaning | Notes |
---|---|---|
alt | Alternative representation type |
|
author | Entry author |
|
category | Category query filter |
|
/-/category | Category query filter |
|
entryID | ID of a specific entry to be retrieved |
|
fields | Response filter |
|
max-results | Maximum number of results to be retrieved | For any service that has a default max-results value (to limit default feed size), you can specify a very large number if you want to receive the entire feed. |
prettyprint | Returns an XML response with identations and line breaks |
|
published-min ,published-max | Bounds on the entry publication date |
|
q | Full-text query string |
|
start-index | 1-based index of the first result to be retrieved |
|
strict | Strict query parameter checking |
|
updated-min ,updated-max | Bounds on the entry update date |
|
as example, if you want to retrieve a list of blog posts with rss format, then the url is as follow
http://www.blogger.com/feeds/blogID/posts/default?alt=rss
or
http://www.example.com/feeds/posts/default?alt=rss
and to publish it, you can use POST method to the following url
POST http://www.blogger.com/feeds/blogID/postID/comments/default
Update a post
For update a post, google has given instruction as follow "To update an existing blog post, first you retrieve the entry you want to update, then you modify it, and then you send a PUT request, with the updated entry in the message body, to the post's edit URL. Be sure that the <id> value in the entry you PUT exactly matches the <id> of the existing entry." If you are doing update, then your feed will contain <updated> tag.Create a comment
If we want to create a comment, create an atom with <entry> tag as follow:and to publish it, you can use POST method to the following url
POST http://www.blogger.com/feeds/blogID/postID/comments/default
Retrieving comments
For retrieving all comments, you can use the following method
GET http://www.blogger.com/feeds/blogID/comments/default
But if you only need comments on specific post, then use the following method
GET http://www.blogger.com/feeds/blogID/postID/comments/default
Delete comments
What you must to do for deleting specific comment is using DELETE method on the specific post.
Import and export
Sometimes you need export to other blog or import from other blog. If you want to export then follow the method below
GET http://www.blogger.com/feeds/blogID/archive
and if you want to import then follow the method below
POST http://www.blogger.com/feeds/blogID/archive/full
Yang saya tidak mengerti, cara memperoleh 'profileId'. Setelah kita berhasil login dan memperoleh 3 id (salah satunya auth=XXX). Nah, bagaimana kita bisa mempopulate seluruh blog yang berada di akun tersebut, padahal kita harus memperoleh terlebih dahulu profileid. Terima kasih.
ReplyDeleteIf you are using blogger profile (not using google+ profile), click that. Then you will get your blogger profile ID.
ReplyDeletemakin bingin saja saya baca2 baca disini.. yang pertama karena pake bahasa inggris, so pasti bahasa inggris saya gk bisa... yang kedua masih lum tahu tentang implementasi json api blogger, tapi saya sangat suka sekali,.. masih tak coba2 semoga berhasil mencobanya...
ReplyDeleteThis was a great guide, I appreciate the fact that you took out all the important stuff out of blogger, my biggest thanks.
ReplyDelete