Picasa Web Albums feeds in JSON format directly
My previous post dealt with using Yahoo's Pipes service to reformat Picasa Web Album RSS feeds as JSON, which was largely just an excuse to try out that service.
However, it's been pointed out to me that Picasa Web Albums feeds can be got directly in JSON, without the need for third party assistance in this way - a fact I'd missed.
To get a Picasa feed as RSS, just append "&alt=json&callback=..." to the normal Picasa RSS request. This isn't documented, but follows the documented conventions that a number of other Google provided feeds are now using.
The equivalent code snippet to match my previous example is
<script>
function output(data)
{
for (var i = 0; i < data.feed.entry.length; i++)
{
var item = data.feed.entry[i];var title = item.title.$t;
var imageurl = item.media$group.media$thumbnail[0].url;
var description = item.media$group.media$description.$t;
var link = item.link[2].href;document.writeln("<a href='" + link + "'><h2>" + title + "</h2><img src='" + imageurl + "'/></a><p>" + description + "</p>");
}}
</script><script src="http://picasaweb.google.com/data/feed/base/user/documentingpicasa?category=album&alt=json&callback=output&access=public"></script>
Examples of people who have been using feeds in this way include:
Thanks to Haochi in the comments of my previous post.
RSS feed
2 Comments:
When using the "api" feed rather than "base", why doesn't
var width = item.gphoto$width;
give the width of the photo?
Any help appreciated.
Ok got it to work needed the following:-
var width = item.gphoto$width.$t
But please could you explain how your code works, in particular what is the significance of the $ in the Javascript. Many thanks.
Post a Comment
Links to this post:
Create a Link
<< Home