Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quick and dirty Google Feed API example, fetching the first image of each feed item.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Google Feed API JSONP Example displaying some Images - wwww.cacodaemon.de</title>
<script type="text/javascript">
function processResults (response) {
var entries = response.responseData.feed.entries;
var images = document.getElementById('images');
for (var i = entries.length - 1; i >= 0; i--) {
if (!entries[i].mediaGroups) {
continue;
}
var imageURL = entries[i].mediaGroups[0].contents[0].url;
var image = document.createElement('img');
image.src = imageURL;
images.appendChild(image);
}
}
function doRequest (src, callback) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = src;
if (callback) {
script.onload = callback;
}
document.getElementsByTagName('head')[0].appendChild(script);
}
doRequest('https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http%3A//api.flickr.com/services/feeds/photos_public.gne%3Fid%3D17472213@N00%26lang%3Den-us%26format%3Drss_200&v=1.0&callback=processResults');
</script>
</head>
<body>
<div id="images"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.