How to query multiple tags in Tumblr's read api?

前端 未结 2 1976

I\'m trying to include Tumblr feeds on a webpage roughly as follows

    $.ajax({
        url: \'http://mypage.tumblr.com/api/read/json?tagged=interesting+tag         


        
2条回答
  •  醉梦人生
    2021-01-01 08:52

    Not possible with the current Tumblr API, it only supports one tag. One workaround is to (aside from pushing for this feature from the Tumblr team) is to use jQuery deferred object to get all the posts with those tags and merge the json results.

    function getPostsByTag(tag) {
       return $.ajax({
        url: 'http://mypage.tumblr.com/api/read/json?tagged=' + tag,
        type: 'GET',
        dataType: 'jsonp'
      });
    };
    
    $.when(getPostsByTag('tag1'), getPostsByTag('tag2'), getPostsByTag('tag3'))
     .then(function() {
       var posts = $.extend({}, arguments);
       renderStuff(posts);
     });
    

提交回复
热议问题