Instagram的GET/tags/< tag>/media/recent分页实际上如何工作? [英] How Does Instagram's GET/tags/<tag>/media/recent Pagination Actually Work?
问题描述
我正在尝试使用实时照片更新 API来获取所有带有它们是特定的标签.由于从该API进行的更新实际上仅告诉您 存在新内容(但不包含什么),因此,我正在用自己的媒体查询最近的媒体每当我收到有关更改的通知时就进行标记.
I'm trying to use the Real-time Photo Updates API to get all pictures with a specific tag as they come in. Since updates from this API really only tell you that new content exists (but not what it is), I am querying for recent media with my tag whenever I get the notification that something has changed.
我遇到的问题是,我不断获取该查询返回的重复介质.该文档说此API可以进行分页,但是我根本无法使它正常工作.
The problem I am having is that I'm constantly getting duplicate media returned by that query. The documentation says this API does pagination, but I can't get it to work at all.
文档此处表示在您的文档中使用min_id
和max_id
查询字符串来控制分页,但是它说:
The documentation here says to use min_id
and max_id
in your query string to control pagination, however it says:
-
MIN_ID-返回此min_id之前的媒体.
MIN_ID - Return media before this min_id.
MAX_ID-在此max_id之后返回媒体.
MAX_ID - Return media after this max_id.
这似乎是倒退的(通常,最小值应该返回大于最小值的项目,最大值应该返回小于最大值的项目,这样当您同时指定两者时,就会得到有界的范围).
This seems backwards (normally min should return items above the minimum and max should return items below the maximum so that when you specify both you get a bounded range).
我从查询中获得的实际JSON包括一个分页对象,如下所示:
The actual JSON I get back from my queries includes a pagination object like this:
"pagination": {
"next_max_tag_id": "1387272337517",
"deprecation_warning": "next_max_id and min_id are deprecated for this endpoint; use min_tag_id and max_tag_id instead",
"next_max_id": "1387272337517",
"next_min_id": "1387272345517",
"min_tag_id": "1387272345517",
"next_url": "https://api.instagram.com/v1/tags/cats/media/recent?access_token=xxx&max_tag_id=1387272337517"
}
在next_url
属性中指定的参数是max_tag_id
,而不是文档所述的max_id
.
The parameter specified in the next_url
property is max_tag_id
, not max_id
like the documentation says.
还有一个弃用警告,指出已弃用next_max_id
和min_id
,但是由于分页对象中具有类似名称的属性,因此我不知道查询参数还是对象属性不推荐使用的..
There is also a deprecation warning that states that next_max_id
and min_id
are deprecated, but since there are properties in the pagination object with names like that, I don't know whether the query parameters or the object properties the ones that are deprecated..
我认为这意味着属性,因为查询字符串从未使用过next_max_id
参数,但是随后弃用消息说使用min_tag_id
和max_tag_id
,并且分页上没有max_tag_id
属性对象(只是一个next_max_tag_id
).
I would think it means the properties, because the query string never used a parameter of next_max_id
, but then the deprecation message says to use min_tag_id
and max_tag_id
and there is no max_tag_id
property on the pagination object (just a next_max_tag_id
).
不管所有这些矛盾的文档如何,我在查询字符串中传递的内容似乎都无关紧要-在后续查询中,我继续获得重复的媒体.有人可以帮我理解这个API吗?我真正想要的只是获得自上次查询以来新的带标签的媒体.
Regardless of all of this conflicting documentation, it doesn't seem to matter what I pass in my query string - I continue to get repeat media in subsequent queries. Can someone help me make sense of this API? All I really want is to get tagged media that is new since my last query.
推荐答案
要获取特定标签的最新克组,请使用以下方法:
To get the newest set of grams for a particular tag, use this:
https://api.instagram.com/v1/tags/latergram/media/recent?access_token=TOKEN
从该响应中,您可以通过从响应中获取min_tag_id
(在分页中)并通过以下方式构建网址来从同一标签中获取新的克数:
From that response, you can get newer grams from the same tag by taking the min_tag_id
from the response (under pagination) and build a url like so:
https://api.instagram.com/v1/tags/latergram/media/recent?access_token=TOKEN&min_tag_id=1387332980547
或者您可以通过使用原始响应(也在分页中)的next_url参数来获取下一组(较旧的)克,如下所示:
Or you can get the next (older) set of grams by using the next_url parameter from the original response (also under pagination), which looks like:
https://api.instagram.com/v1/tags/latergram/media/recent?access_token=TOKEN&max_tag_id=1387332905573
确保您的后续查询(针对特定标签的新克数)使用的是最新响应返回的min_tag_id
.我做了一些测试,没有发现重复,但是我使用的是#latergram,并且其中有大量的帖子
Make sure your subsequent queries (for new grams of a particular tag) are using the min_tag_id
returned by the latest response. I did a few tests and didn't see duplicates, however I was using #latergram and that one has a high volume of posts
这篇关于Instagram的GET/tags/< tag>/media/recent分页实际上如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!