如何查询多个标签的tumblr的读取API? [英] How to query multiple tags in Tumblr's read api?

查看:326
本文介绍了如何查询多个标签的tumblr的读取API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想包括的tumblr网页上的饲料大致如下:

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',
        type: 'GET',
        dataType: 'jsonp',
        success: renderStuff,
        error: function () {
            alert('D\'oh'!)
        }
    });

现在,这工作得很好:我得到的所有条目标签有趣的标签

Now, this works fine: I get all entries with the tag 'interesting tag'.

我的问题是:我如何要求多个标签?改变这样的查询字符串

My question is: How do I ask for multiple tags? Changing the query string like this

'http://mypage.tumblr.com/api/read/json?tagged=tag1&tagged=tag2&tagged=tag3'

只返回条目TAG3。

only returns entries with 'tag3'.

有一些窍门和或或标签的名字连在一起?如果不是这样,我会很高兴,只是查询所有这些,手动筛选他们,但我认为这将是值得一问。

Is there some trick to 'AND' or 'OR' tag-names together? If not, I'd be happy to just query all of them and filter them manually but I thought it would be worth asking.

在此先感谢的人!

推荐答案

不可能与当前的tumblr API,它仅支持一个标记。一种解决方法是(除了推动从球队的tumblr此功能)是使用jQuery推迟对象来获取所有这些标签的职位和合并的JSON结果。

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);
 });

这篇关于如何查询多个标签的tumblr的读取API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆