Fetching tags with Instagram API

假如想象 提交于 2019-12-24 12:19:58

问题


I am trying to use the following URL: https://api.instagram.com/v1/tags/snow/media/recent?access_token=x&min_id=x&max_id=x to fetch some images and their ID's. It's working fine, but how can I have more images? I want thousands of images, but I'm only getting about 30 at most. I'm guessing it has to do with the min_id and max_id, but I can't get any more images. Could anyone help me out?

Edit: I found out that Instagram has a 20 result limit. Is there any way using C# that will allow me to fetch older pictures for a total of X amount of pictures?


回答1:


You will need to use the pagination property in the response for paging through results. Look for the next_url property in the pagination object for the next url to call.

You can add a count parameter to your call to specify the number of records to receive for each call. This count parameter has a maximum value of 50 (or maybe 20) I think, I can't remember the exact number.

So return your first 20 records, then call the next_url property to get the next 20 images for the tag you specified.

Look in the response you get back from Instagram for the pagination property:

{

    pagination: {"next_max_tag_id": "12345678", "next_max_id": "12345678",
    "next_min_id": "12345678",
    "min_tag_id": "12345678",
    "next_url": "THE URL WILL BE HERE"}

    data: {}

}



回答2:


Using the Instasharp Client library (https://github.com/InstaSharp/InstaSharp) you can do something like this:

var tags = new Endpoints.Tags(Config);
var result = await tags.RecentMultiplePages("csharp", minTagId: null, maxTagId: null, maxPageCount: 3);

You can inspect the result.RateLimitRemaining property to ensure you're not going to get blocked for spammy behaviour.



来源:https://stackoverflow.com/questions/18435691/fetching-tags-with-instagram-api

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