Smart Recent Blog Post List

Sep 18, 2011

List of Blog Post Gadget for blogger using javascript

Blogger Data API Sample

Following post will help in retrieving the information related to list of post from a blog. One can use this to display the list of blogs by following easy step mentioned below

 1) Add one html/javascript gadget to your blog.

2) Copy paste below code to your gadget.

3) Replace feeduri with your blog feed uri.

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

 4) just save the gadget and its ready to use. Here goes the code for list of post for a blog :-








-------------------------------------------------------------------------------------------

/* 
* Retrieve a list of blog posts
*/

// Obtain a reference to the 'content' div
var content = document.getElementById('content');

// Create the blogger service object
var bloggerService =
    new google.gdata.blogger.BloggerService('com.appspot.interactivesampler');

// The feed for a single blog. (In this case, the Official Google Blog.)
//
// The ID included in this URI can be retrieved from the
// <link rel="service.post"> element in the Blog's HTML source
var feedUri = 'http://www.blogger.com/feeds/10861780/posts/default';

// A callback method invoked getBlogPostFeed() returns data
var handleBlogPostFeed = function(postsFeedRoot) {
  var posts = postsFeedRoot.feed.getEntries();
  
  // This variable will buffer HTML output until function completes
  var html = '';
  
  // Display blog's title
  html += '<dl>'
       + '<dt><strong>Blog:</strong> '
       + '<a href="'
       + postsFeedRoot.feed.getLink('alternate').getHref()
       + '">'
       + postsFeedRoot.feed.getTitle().getText()
       + '</a></dt>';
  
  // Display blog posts
  html += '<dd><ul>';
  for (var i = 0, post; post = posts[i]; i++) {
    var postTitle = post.getTitle().getText();
    var postURL = post.getHtmlLink().getHref();
    html += '<li><a href="' + postURL + '" target="_blank">'
              + postTitle
              + '</a></li>';
  }
  html += '</ul></dd>';
  
  // Write out buffered HTML, and clear the "Loading..." message
  content.innerHTML = html;
};

var handleError = function(error) {
  content.innerHTML = '<pre>' + error + '</pre>';
};

bloggerService.getBlogPostFeed(feedUri, handleBlogPostFeed, handleError);

------------------------------------------------------------------------------------------------------

 

Below is the demo of above code for my blog :-

 





Loading...



26 comments:

ผมอยากให้googleกับfirefoxจับมือกันเพื่อความสําเร็จและก้าวหน้า

Blogspot post list javascript

i found your site through search, yours site is a nice and excellent website.. contents are nice.. will grow higher in future


http://winterreifen.ms/

tried it step by step and changed the blog url, not working though

what exactly you are getting as output, and specify error if you are getting any

Hi, i get this as output when i paste the code in the default HTML/Javascript widget

// Obtain a reference to the 'content' div var content = document.getElementById('content'); // Create the blogger service object var bloggerService = new google.gdata.blogger.BloggerService('com.appspot.interactivesampler'); // The feed for a single blog. (In this case, the Official Google Blog.) // // The ID included in this URI can be retrieved from the // element in the Blog's HTML source var feedUri = 'http://interblog.blogspot.com/feeds/posts/default'; // A callback method invoked getBlogPostFeed() returns data var handleBlogPostFeed = function(postsFeedRoot) { var posts = postsFeedRoot.feed.getEntries(); // This variable will buffer HTML output until function completes var html = ''; // Display blog's title html += '

' + '
Blog: ' + '' + postsFeedRoot.feed.getTitle().getText() + ''; // Display blog posts html += '

'; for (var i = 0, post; post = posts[i]; i++) { var postTitle = post.getTitle().getText(); var postURL = post.getHtmlLink().getHref(); html += '
' + postTitle + '
'; } html += '

'; // Write out buffered HTML, and clear the "Loading..." message content.innerHTML = html; }; var handleError = function(error) { content.innerHTML = '

' + error + '

'; }; bloggerService.getBlogPostFeed(feedUri, handleBlogPostFeed, handleError);

Good presentation, You give is very helpful and we thank you very much..

Thanks for your suggestions. It helped me to develop my site http://learningmsofficepackage.blogspot.com

Wish you all the best.

Very nice post.
Get more offer of online mobile recharge and DTH at cuponswall freecharge India.

Learning new technolgoy would help oneself at hard part of their career. And staying updated is the only way to survive in current position. Your content tells the same. Thanks for sharing this information in here. Keep blogging like this.

Best JAVA Training institute in Chennai | Best JAVA Training in Chennai | Hadoop training in chennai

Many website builders rely on JavaScript to make their websites functional. Functions such as drop down menus, image changes, and linking to other websites are all done through the JavaScript program.
See more at: javascript

Thanks for sharing this post.There are more job vacancies in IT sectors.JAVA is really useful for IT professionals.
Regards

Java courses in Chennai |
Best JAVA Training in chennai

Your content is nice and understandable.Keep sharing like this.
Regards,
Hadoop course in Chennai |
Hadoop Training institutes in Chennai

The expansion of internet and other business intelligence leads to large volume of data. Industries are looking for talented professionals to maintain and process huge volume of data with latest tools available in the market. Taking Hadoop Training in Chennai | Big Data Training in Chennai will ensure better career prospects for talented professionals.

Hello,
you have written a great article on gadget for blogger do check out some article in my blog gadjet geek

I have read your blog its very attractive and impressive. I like it your blog.
Java Training institute in velachery

Croma campus is best IT training institute and best class IT trainer provides croma campus is great JavaScript training in noida wiht jo b placement support. croma campus best facilities and lab provides then best option for you join us croma campus

This blog is very informative about the concepts involved in hadoop and its scope in future. Interesting concepts on its architectute and syllabus which are covered by big data hadoop training institute in Chennai that is functioning effectively.

Really a good technical site,keep on writing good stuffs
dot net training in chennai

Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…
Regards,
PHP Training Chennai|PHP Training Institute in Chennai

Post a Comment

Smart Recent Blog Post List