将下面代码中的“tester”用户名替换为你的用户名,并将目标值替换为你想要将图片追加到的元素的选择器。
$(document).ready(function() {
$.getJSON("http://picasaweb.google.com/data/feed/base/user/tester/?kind=photo&access=public&alt=json&callback=?",
function(data) {
var target = "#latest-picasaweb-images ul"; // Where is it going?
for (i = 0; i <= 9; i = i + 1) { // Loop through the 10 most recent, [0-9]
var pic = data.feed.entry[i].media$group;
var liNumber = i + 1; // Add class to each LI (1-10)
var thumbSize = 0; // Size of thumbnail - 0=small 1=medium 2=large
$(target).append("<li class='no-" + liNumber + "'><a title='" + pic.media$description.$t + "' href='" + pic.media$content[0].url + "'><img src='" + pic.media$thumbnail[thumbSize].url + "' /></a></li>");
}
});
});
自从编写并使用此代码一段时间后,我注意到它并不能完全获取绝对最新的图片,而更像是代表性的图片,例如你一次上传的 5 张图片中的 1 张。
但他们的 RSS Feed 也一样,所以我猜这应该是 Google 的普遍做法,谁又能责怪他们呢。他们不可能为每张照片都提供绝对准确的实时 Feed...
如果你想显示你拥有的图片数量,试试这个代码
参考 URL
https://developers.google.com/picasa-web/docs/2.0/reference
感谢您,已更新该链接并隐藏它,因为它不再相关。