Instagram /v1/tags/{tag-name}/media/recent endpoint doesn't return min_tag_id in pagination block

本小妞迷上赌 提交于 2019-11-27 20:19:05

问题


According to https://www.instagram.com/developer/endpoints/tags/, we used to get the min_tag_id in the pagination part of the https://api.instagram.com/v1/tags/tag-name/media/recent?access_token=ACCESS-TOKEN response which we then used in the request to poll for newer posts.

As of this morning, we saw that Instagram changed the form of the pagination response. It now looks something like:

"pagination": {
"next_max_tag_id": "AQBy529IMOAlOvp6EI5zrYZRZbUbNW2oGQjgdvfVi5I_7wTIKzqE2nfsSBHvCkPmWOMKV7kmNcMPErenGJsbDtIk013aPZ_xo4vFYuXqtDGz3ZS0ZBrnTSjtuGjtnEOHiDJlAp8lI99AuwAgObnaf6tYhkoiDajEkg5E2zOFuDZFfQ",
"next_url": "https://api.instagram.com/v1/tags/enplug/media/recent?access_token=1573931388.852f6fb.2ee7fb644c5341dd813bd3bbc4c687ec&max_tag_id=AQBy529IMOAlOvp6EI5zrYZRZbUbNW2oGQjgdvfVi5I_7wTIKzqE2nfsSBHvCkPmWOMKV7kmNcMPErenGJsbDtIk013aPZ_xo4vFYuXqtDGz3ZS0ZBrnTSjtuGjtnEOHiDJlAp8lI99AuwAgObnaf6tYhkoiDajEkg5E2zOFuDZFfQ",
"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": "AQBy529IMOAlOvp6EI5zrYZRZbUbNW2oGQjgdvfVi5I_7wTIKzqE2nfsSBHvCkPmWOMKV7kmNcMPErenGJsbDtIk013aPZ_xo4vFYuXqtDGz3ZS0ZBrnTSjtuGjtnEOHiDJlAp8lI99AuwAgObnaf6tYhkoiDajEkg5E2zOFuDZFfQ"
}

Is min_tag_id now deprecated? The developer docs don't mention anything about this.


回答1:


It seems this was a temporary issue with the Instagram API and has now been resolved.




回答2:


So upon further investigation, I noticed that you can use the id of the newest post to effectively filter out older posts from the https://api.instagram.com/v1/tags/tag-name/media/recent?access_token=ACCESS-TOKEN response, which now always returns the last 20 posts.

An id of a instagram post typically looks like xxxxxxxxxxxxxxxxxxx_yyyyyyyyyy where xxxxxxxxxxxxxxxxxxx is essentially the min_tag_id that used to be returned in the pagination block and yyyyyyyyyy is the user's id.

So you can extract the xxxxxxxxxxxxxxxxxxx part of a post's id(xxxxxxxxxxxxxxxxxxx_yyyyyyyyyy) and do a comparison to see if it is larger than the previous xxxxxxxxxxxxxxxxxxx that you were keeping track of to retrieve newer posts.



来源:https://stackoverflow.com/questions/36166770/instagram-v1-tags-tag-name-media-recent-endpoint-doesnt-return-min-tag-id-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!