Instagram Gem: Get Photos with Specific Hashtags

Is it possible to select only images with certain hashtags from the user using the instagram gem? Could not find hashtig in documents. If yes, provide an example.

+4
source share
1 answer

This cannot be done directly. The Instagram API itself does not allow you to make such a call: you need to either request specific user photos or request a tag, and the gem does not provide a workaround.

So first, request the user:

@results = Instagram.user_recent_media(1907035, {access_token: t.token, count: 60}) # 60 appears to be the max 

Then save the photos with the desired tags. In the results, each element has an array of "tags". For example, @results.first["tags"] returns an array of tags for the first photo.

Here's some well-documented code for creating typical queries:

https://github.com/Instagram/instagram-ruby-gem/blob/master/lib/instagram/client/users.rb

+8
source

Source: https://habr.com/ru/post/1414011/


All Articles