admin 管理员组文章数量: 1086019
I'm trying to include Tumblr feeds on a webpage roughly as follows
$.ajax({
url: '+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
';tagged=tag2&tagged=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.
Thanks in advance people!!
I'm trying to include Tumblr feeds on a webpage roughly as follows
$.ajax({
url: 'http://mypage.tumblr./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./api/read/json?tagged=tag1&tagged=tag2&tagged=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.
Thanks in advance people!!
Share Improve this question asked May 18, 2011 at 10:19 HumanCatfoodHumanCatfood 1,0111 gold badge9 silver badges21 bronze badges2 Answers
Reset to default 7Not 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./api/read/json?tagged=' + tag,
type: 'GET',
dataType: 'jsonp'
});
};
$.when(getPostsByTag('tag1'), getPostsByTag('tag2'), getPostsByTag('tag3'))
.then(function() {
var posts = $.extend({}, arguments);
renderStuff(posts);
});
From Tumblr API Docs : tagged - Return posts with this tag in reverse-chronological order (newest first).
with this tag is self explanatory, I think.
So, you'll have to make several requests, sorry
本文标签: javascriptHow to query multiple tags in Tumblr39s read apiStack Overflow
版权声明:本文标题:javascript - How to query multiple tags in Tumblr's read api? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744097213a2533119.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论