Google’s new Feed API
JSONP feeds are great! They allow you to access information in a secure way across domains, build slim mashups and keep the load off your own servers. Sadly though they aren’t as widespread as many of us would like them to be, still RSS Feeds and Atom Feeds have the majority. But now Google comes into play: the new Service from the Google Ajax API’s team Google AJAX Feed not only translates RSS and Atom Feeds into JSONP Feeds, but also caches them for you, speeding up the loading, and keeping the load off the publishers side (a feature Digg & Co. will be grateful for).
And so with only a few lines of code
you can grab the Digg.com feed via Javascript.<html>
<head>
<script type="text/javascript" src="http://www.google.com/jsapi?key=YOUR_KEY_HERE"></script>
<script type="text/javascript">
google.load("feeds", "1");
function initialize() {
var feed = new google.feeds.Feed("http://www.digg.com/rss/index.xml");
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 div = document.createElement("div");
div.appendChild(document.createTextNode(entry.title));
container.appendChild(div);
}
}
});
}
google.setOnLoadCallback(initialize);
</script>
</script></head>
<body>
<div id="feed"></div>
</body>
</html>
What a beautiful day to be a developer
