Tumblr API - “标记抓取”脚本不显示图像

时间:2015-08-25 21:20:17

标签: javascript ajax tumblr

到目前为止,我有这个。它应该从'cyberpunk'标签中抓取图像并将其发布到<body>,但它不起作用。为什么?有关Tumblr API的更多信息,请访问here

<script>
  $(document).ready(function (){
    var link = "http://api.tumblr.com/v2/tagged?tag=cyberpunk";
    $.ajax({
      type: "GET",
      url : link,
      dataType: "jsonp", 
      data: {
          api_key: "PgAKpKfv1Tcjo1uhsKEuriThhwH9XDJonRobaGwckw8RJt2tos"
      }
    }).done(function( data ) {
      $.each(data.response.posts, function(){
        var _photos = this.photos;

        $.each(_photos, function(){
          $('body').append("<img src='" + this.original_size.url + "'/>");
        });
      });
    });
  });
</script>

1 个答案:

答案 0 :(得分:2)

仅为data.response,而不是data.response.posts,所以

//your code...
//..

 $.each(data.response, function(){ //
//.. rest of your code