【发布时间】:2013-10-04 00:21:10
【问题描述】:
我正在使用 Tumblr API 在我的网站上生成图片。
我可以获取照片及其 URL,但不能获取标题。
我制作了一个脚本,它可以像这样简单地遍历帖子:
成功:函数(结果){
var i = 0;
while (i < results.response.posts.length) {
if (type == "photo") {
var photourl = results.response.posts[i].photos[0].alt_sizes[0].url;
var caption = results.response.posts[i].caption;
$("#tumnews #newscara").append("<li><div class='tumpost'><a href='" + link + "'><img src='" + photourl + "' alt='" + title + "'/><div class='tumcaption'>" + caption + "</div></a></div></li>");
}
i++;
}//END WHILE
但我无法检索字幕的数据,即使文档说它只是使用术语“字幕”(http://www.tumblr.com/docs/en/api/v2#photo-posts) 检索。
我也试过了:
var caption = results.response.posts[i].photos[0].caption;
和
var caption = results.response.posts[i]photos[0].caption[0];
但我没有得到任何结果 - 甚至没有任何错误。
有人知道如何正确地做到这一点吗?
【问题讨论】:
标签: jquery ajax json api tumblr