Module: InstagramGraphApi::Client::Tag

Included in:
InstagramGraphApi::Client
Defined in:
lib/instagram_graph_api/client/tag.rb

Instance Method Summary collapse

Instance Method Details

#tag_media(page_token, tag_name, fields = nil, edge: "top_media", options: {}) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/instagram_graph_api/client/tag.rb', line 4

def tag_media(page_token, tag_name, fields = nil, edge: "top_media", options: {})
  user_id = get_ig_id_from_token(page_token)
  tag_info = graph_call("ig_hashtag_search?user_id=#{user_id}&q=#{tag_name}")[0]
  fields ||= "id,media_type,comments_count,like_count,media_url,permalink"
  query = "#{edge}?user_id=#{user_id}&fields=#{fields}"
  query += options.reduce(""){|s, (k, v)| s+= "&#{k}=#{v}" }
  get_connections(tag_info["id"], query)
end