WhatsApp Chat
Send us a message today and we will contact you as soon as possible.

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