Kinetic Pulse
  • Home
  • Services
  • Portfolio
  • Blog
  • Terms
  • Contact

Using Google API to get feed from Blogger

August 7, 2014

I had previously used the php library SimplePie to pull in blog posts from a clients Blogger blog to show on the their Zencart site.

And it worked well – until the hosts did a PHP upgrade and it stopped working (thanks 1&1!)

No matter what I tried – different versions of SimplePie, debugging lines of code – would make it work again. So I needed another solution.

Google to the rescue. Using their Google Feed API I managed to pull the feed data into the page:

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

    google.load("feeds", "1");

    function initialize() {
      var feed = new google.feeds.Feed("http://lawandcompany.blogspot.com/feeds/posts/default");
      feed.setNumEntries(10);
      feed.load(function(result) {
        if (!result.error) {
          var container = document.getElementById("feed");
          for (var i = 0; i < result.feed.entries.length; i++) {
            var entry = result.feed.entries[i];
            var h2 = document.createElement("h2");
            h2.innerHTML="<a href='"+entry.link+"'>"+entry.title+"</a>";
            container.appendChild(h2);
	    var content = document.createElement("p");
            content.innerHTML = entry.content;
            container.appendChild(content)
	    var postdate = document.createElement("p");
	    var d = new Date(entry.publishedDate);
	    var curr_date = d.getDate();
	    var curr_month = d.getMonth() + 1; //Months are zero based
	    var curr_year = d.getFullYear();
             postdate.innerHTML ="<small>Posted on: "+curr_date + "-" + curr_month + "-" + curr_year+"</small>";
            container.appendChild(postdate)
          }
        }
      });
    }
    google.setOnLoadCallback(initialize);

    </script>
    <div id="feed" class="item"></div>

You can see it in action here:
http://www.lawandcompany.com/blog

Testimonials

I like it.  I like it a lot !!!

 You have interpreted what I wanted to achieve perfectly considering what you have to play with i.e not redoing the whole thing in the process.

Fiona Simmons-MooreSouth Gloucestershire Parents & Carers
Absolutely fantastically professional web developer – I would highly recommend!!! Thank you so much Kinetic Pulse!
Tania MarstonDoris Designs
Amazing and brilliant, Kinetic Pulse have lifted a dream to reality, Highly recommended and great if you are total novice, they know their stuff…Thanks again
Annie LindridgeSalt Yourself Out
Thank you for all of your hard work its looks fab and I am over the moon with it!
Amanda MercerAmanda Mercer Ceramics
It’s been fab working with you – we love the site and certainly going to recommend you!
James DaviesThirty Eight Degrees North
Thank you guys so much for all that you’ve done helping us to create a really awesome website!! We get such great feedback – everyone loves it & we couldn’t be prouder! Look forward to working with you again soon!
Wild Thyme PlantsWild Thyme Plants
Thanks so much for all your work on this, really appreciated. It’s come on in leaps and bounds since you took over.
Pete KewRedwood Strip Curtains

Copyright 2025 Kinetic Pulse