Module: InstagramGraphApi::Client::Discovery

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

Instance Method Summary collapse

Instance Method Details

#discover_user(username, fields = nil) ⇒ Object



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

def discover_user(username, fields = nil)
  fields ||= "id,followers_count,media_count,ig_id"
  bg_id = 
  raise "No business-account found, you need to have atleast one IG business-account" unless bg_id
  query = "?fields=business_discovery.username(#{username}){#{fields}}"
  get_connections(bg_id, query)
rescue Exception => e
  puts e.message
end

#discover_user_media(username, fields = nil, options = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/instagram_graph_api/client/discovery.rb', line 14

def discover_user_media(username, fields = nil, options={})
  fields ||= "caption,media_url,media_type,like_count,comments_count,id"
  page_options = ".after(#{options['after']})" if options["after"]
  page_options = ".after(#{options['before']})" if options["before"]
  discover_user(username, "media#{page_options}{#{fields}}")
end