Learn More

Saturday, April 14, 2012

Basic Blogger JavaScript API

blogger api logo
Blogger JavaScript API allows client applications to view and update the blog content. Edit, delete, add to each post or comment on your blog you can do via the blogger javascript API in the form of google data API feeds. This can not be performed (at this post published) by the blogger JSON API. With this API, you can make the blog more interactive. This post is very useful for you to learn the basic of how to use the blogger javascript API.

Prior to that, we suggest you to read about the, blogger developer javascript APIbasic blogger api, protocol section, google javascript api, using basic javascript client library, basic google data API, google data API protocol. And also, you must be able in javascript programming language. Not only that, you follow the term of use.

The first step to start is by placing the following code after <head>

<script type="text/javascript" src="http://www.google.com/jsapi"></ script>

Remember, this applies to public blog. In addition, you must create authentic. There are two ways at preloading the library. First, without using google.load(), in here you can repair the code above with

<script type="text/javascript" src="http://www.google.com/jsapi?autoload={modules:[{name:gdata,version:2.x,packages:[blogger,contacts]}]}"></script>.

this is more simple in roundtrips and latency. Second, with using google.load(). After <script type="text/javascript" src="http://www.google.com/jsapi"></script>, you must add the code below

google.load("gdata", "2.x", {packages: ["blogger", "contacts"]});

Meaning of  "2.x" is the very latest revision of major version 2.

After you've called google.load(), you have to tell the loader to wait until the page finishes loading and then call your code:


Where getMyFeed() is a function defined in the next section of this document.

Now, if you are using non authentic, what you need first is call getMyFeed().  Create a connection to getMyFeed() with setupMyService() function. Then, call the library into getMyFeed(). See the example below

var feedUri = 'http://www.blogger.com/feeds/4999557720148026925/posts/default';

function setupMyService() {
var bloggerService = new google.gdata.blogger.BloggerService('com.appspot.interactivesampler');
  return bloggerService;

function getMyFeed() {
bloggerService= setupMyService();

bloggerService.getBlogCommentFeed(commentsFeedUri, handleCommentFeed, handleError);

Yes, you must create a function to for handle comment feed and to handle error when the library is not supported by browser. See the example below

function handleCommentFeed(myResultsFeedRoot) {
  alert("This feed's title is: " + myResultsFeedRoot.feed.getTitle().getText());

function handleError(e) {
  alert("There was an error!");
  alert(e.cause ? e.cause.statusText : e.message);

Post a Comment