Instagram API-获取所有用户的特定标签或位置

问题描述:

我已经开始研究Instagram API,并且希望撤出所有使用特定#标签或位于给定位置的用户.

I've started looking into the Instagram API and I want to pull out ALL users that have used a specific hashtag or have been at a given location.

如文档所述,我可以使用以下方法获取最近使用过#标签和位置信息的用户:

As the documentation says I can get the RECENT users for a hashtag and location using the following methods:

https://api.instagram.com/v1/tags/{tag}/media/recent?access_token={token}

https://api.instagram.com/v1/media/search?lat={latitude}&lng={longitude}&access_token={token}

我正在获取这些的最新数据(最多7分钟).我的问题是,是否有可能检索所有用户,而不仅仅是最近的用户?另外,如何获取位置名称(例如伦敦")的媒体对象?看来我必须先获取位置的位置ID,但是文档中并未明确说明如何获取ID.

I am getting the recent (up to 7 minutes old) data with these. My question is if it is possible to retrieve ALL users, not just the recent? Also, how can I get media objects for a name of a location, for example "London"? It seems like I have to get the location ID of the location first, but the documentation doesn't make it clear how to get the ID.

按主题标签或位置获取用户

据我所知,没有一个整洁的端点可以通过标签或位置来获取用户数据.我认为,从标签,位置或地理位置最近的媒体端点获取所有用户的唯一方法是宰杀API并从这些端点上每个分页响应的data数组中的每个项目中获取user对象.每个响应中都有一个与data级别相同的pagination属性,可以帮助您完成此操作.

Getting users by hashtag or location

To my knowledge, there isn't a tidy endpoint for getting user data by hashtag or location. I think the only way to get all users from the Tags, Locations, or Geographies recent media endpoints is to slaughter the API and scape the user object from each item in the data array from each paginated response on those endpoints. There's a pagination attribute on the same level as data in each response that helps you do this.

"pagination": { "next_max_tag_id": "1009570282366298753", "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": "1009570282366298753", "next_min_id": "1009570411710268632", "min_tag_id": "1009570411710268632", "next_url": "https://api.instagram.com/v1/tags/{tag}/media/recent?access_token={access_token}&max_tag_id=1009570282366298753" },

"pagination": { "next_max_tag_id": "1009570282366298753", "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": "1009570282366298753", "next_min_id": "1009570411710268632", "min_tag_id": "1009570411710268632", "next_url": "https://api.instagram.com/v1/tags/{tag}/media/recent?access_token={access_token}&max_tag_id=1009570282366298753" },

pagination.next_url将在当前响应之后为您提供另一页响应,该页面将具有新的pagination.next_url,依此类推.

pagination.next_url is going to get you another page of responses later than the current response, which will have a new pagination.next_url and so on.

您可以在GET URL ?count=33中传递一个附加参数,该参数指定在data数组中获取的对象数,最大值为33.因此,每个请求可以获得33个结果,而不是默认的20个每个请求.

You can pass an additional parameter in your GET URL ?count=33, this specifies the number of objects you get in the data array, the max is 33. So you can get 33 results per request instead of the default 20 per request.

位置媒体最新端点"仅适用于位置ID,但是可以从任何最近的媒体端点在data数组中对象的location属性中找到位置ID.仅当该图片已地理位置定位并指定了位置(与Instagram API不同)时,才会填充该属性.

The Location Media Recent Endpoint only works on location ID, but location ID can be found in the location property of an object in the data array from any recent media endpoint. That property will only be populated if that image was geo-located and a location was specified, which are different to the Instagram API.

使用位置搜索端点并在结果,直到找到所需的位置.

It'd probably be easier just to use the location search endpoint and search through the results until you find the location your looking for.

https://api.instagram.com/v1/locations/search?lat={latitude}&lng={longitude}&distance={radius_in_meters}&access_token={access_token}