instagram_graph_api 0.0.6 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/lib/instagram_graph_api/client.rb +1 -3
- data/lib/instagram_graph_api/client/discovery.rb +4 -2
- data/lib/instagram_graph_api/client/insights.rb +21 -0
- data/lib/instagram_graph_api/client/media.rb +4 -17
- data/lib/instagram_graph_api/client/users.rb +8 -0
- data/lib/instagram_graph_api/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9153f06a78e929e20d035b7d31654ab321b7386d173d0d03adb75ed490cdb0cc
|
4
|
+
data.tar.gz: 0f9c5367c3fc0200877c1454a7820ee786cbe16a95694bfc6a68055190ca1343
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1954017b27cf3fa50e6a50a04f64a12cf7edbc689adf0fd6cd59fa0bf3bb8ee19db87154aa2d07dd248afbc1f7c13d36293731535e433c4790ed2c7f2d527e07
|
7
|
+
data.tar.gz: ed977b4c4742ee3f8af8693e807e526836db551fb20a5359307c09457ace45c448b1c19afd3cd20ce443e50507326f8b1f9c9d25c66f71d20427a587ca2075e1
|
data/README.md
CHANGED
@@ -25,8 +25,14 @@ client = InstagramGraphApi.client(ACCESS_TOKEN)
|
|
25
25
|
|
26
26
|
#get an arraay of business accounts linked to the access_token
|
27
27
|
client.ig_business_accounts
|
28
|
+
#get an array of connected IG accounts linked to the access_token
|
29
|
+
client.connected_ig_accounts
|
28
30
|
|
29
|
-
#get
|
31
|
+
#to get specific fields from "id,name,biography,ig_id,followers_count,profile_picture_url,username"
|
32
|
+
client.ig_business_accounts("name,followers_count")
|
33
|
+
client.connected_ig_accounts("name,followers_count")
|
34
|
+
|
35
|
+
#get IG business account/ Connected IG account info
|
30
36
|
client.get_account_info(IG_BUSINESS_ID)
|
31
37
|
#to get specific fields
|
32
38
|
fields = "name, biography"
|
@@ -4,12 +4,10 @@ module InstagramGraphApi
|
|
4
4
|
class Client < Koala::Facebook::API
|
5
5
|
Dir[File.expand_path('../client/*.rb', __FILE__)].each{|f| require f}
|
6
6
|
|
7
|
+
include InstagramGraphApi::Client::Insights
|
7
8
|
include InstagramGraphApi::Client::Users
|
8
9
|
include InstagramGraphApi::Client::Media
|
9
10
|
include InstagramGraphApi::Client::Discovery
|
10
11
|
|
11
|
-
def initialize(media_id = nil, access_token)
|
12
|
-
super(access_token)
|
13
|
-
end
|
14
12
|
end
|
15
13
|
end
|
@@ -11,9 +11,11 @@ module InstagramGraphApi
|
|
11
11
|
puts e.message
|
12
12
|
end
|
13
13
|
|
14
|
-
def discover_user_media(username, fields = nil)
|
14
|
+
def discover_user_media(username, fields = nil, options={})
|
15
15
|
fields ||= "caption,media_url,media_type,like_count,comments_count,id"
|
16
|
-
|
16
|
+
page_options = ".after(#{options['after']})" if options["after"]
|
17
|
+
page_options = ".after(#{options['before']})" if options["before"]
|
18
|
+
discover_user(username, "media#{page_options}{#{fields}}")
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module InstagramGraphApi
|
2
|
+
class Client
|
3
|
+
module Insights
|
4
|
+
|
5
|
+
METRIC_HASH = {
|
6
|
+
image: 'impressions,reach',
|
7
|
+
video: 'impressions,reach,video_views',
|
8
|
+
story: 'impressions,replies,reach,taps_forward,taps_back,exits'
|
9
|
+
}
|
10
|
+
|
11
|
+
def insights(object_id, type: "image", metrics: nil)
|
12
|
+
metrics ||= METRIC_HASH[type.to_sym]
|
13
|
+
@raw_insights = get_connections(object_id, "insights?metric=#{metrics}")
|
14
|
+
@raw_insights.reduce({}) do |result, insight_data|
|
15
|
+
result[insight_data["name"]] = insight_data["values"].first["value"]
|
16
|
+
result
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -3,12 +3,6 @@ module InstagramGraphApi
|
|
3
3
|
module Media
|
4
4
|
attr_accessor :media_info, :raw_insights
|
5
5
|
|
6
|
-
METRIC_HASH = {
|
7
|
-
image: 'impressions,reach',
|
8
|
-
video: 'impressions,reach,video_views',
|
9
|
-
story: 'impressions,replies,reach,taps_forward,taps_back,exits'
|
10
|
-
}
|
11
|
-
|
12
6
|
MEDIA_INFO_HASH = {
|
13
7
|
image: "comments_count,like_count,media_type,"\
|
14
8
|
"media_url,permalink,timestamp,thumbnail_url",
|
@@ -18,27 +12,20 @@ module InstagramGraphApi
|
|
18
12
|
"timestamp,thumbnail_url"
|
19
13
|
}
|
20
14
|
|
21
|
-
def get_user_recent_media(id, type: "image", options: {})
|
15
|
+
def get_user_recent_media(id, fields = nil, type: "image", options: {})
|
22
16
|
entity = type.eql?("story") ? "stories" : "media"
|
23
|
-
|
17
|
+
fields ||= MEDIA_INFO_HASH[type.to_sym]
|
18
|
+
query = "#{entity}?fields=#{fields}"
|
24
19
|
query += "&after=#{options[:after]}" if options[:after]
|
25
20
|
query += "&before=#{options[:before]}" if options[:before]
|
26
21
|
get_connections(id, query)
|
27
22
|
end
|
28
23
|
|
29
|
-
def get_media_details(media_id, type: "image")
|
24
|
+
def get_media_details(media_id, fields = nil, type: "image")
|
30
25
|
fields ||= MEDIA_INFO_HASH[type.to_sym]
|
31
26
|
get_connections(media_id , "?fields=#{fields}")
|
32
27
|
end
|
33
28
|
|
34
|
-
def insights(media_id, type: "image", metrics: nil)
|
35
|
-
metrics ||= METRIC_HASH[type.to_sym]
|
36
|
-
@raw_insights = get_connections(media_id , "insights?metric=#{metrics}")
|
37
|
-
@raw_insights.reduce({}) do |result, insight_data|
|
38
|
-
result[insight_data["name"]] = insight_data["values"].first["value"]
|
39
|
-
result
|
40
|
-
end
|
41
|
-
end
|
42
29
|
end
|
43
30
|
end
|
44
31
|
end
|
@@ -9,6 +9,14 @@ module InstagramGraphApi
|
|
9
9
|
end.compact
|
10
10
|
end
|
11
11
|
|
12
|
+
def connected_ig_accounts(fields = nil)
|
13
|
+
fields ||= 'id,name,biography,ig_id,followers_count,profile_picture_url,username'
|
14
|
+
accounts = get_pages("?fields=connected_instagram_account{#{fields}}")
|
15
|
+
accounts.map do |a|
|
16
|
+
a["connected_instagram_account"].merge(page_id: a["id"]) if a["connected_instagram_account"]
|
17
|
+
end.compact
|
18
|
+
end
|
19
|
+
|
12
20
|
def get_account_info(ig_account_id, fields = nil)
|
13
21
|
fields ||= "biography,followers_count,ig_id,name,profile_picture_url,username,id"
|
14
22
|
get_connections(ig_account_id , "?fields=#{fields}")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: instagram_graph_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rakesh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- lib/instagram_graph_api.rb
|
87
87
|
- lib/instagram_graph_api/client.rb
|
88
88
|
- lib/instagram_graph_api/client/discovery.rb
|
89
|
+
- lib/instagram_graph_api/client/insights.rb
|
89
90
|
- lib/instagram_graph_api/client/media.rb
|
90
91
|
- lib/instagram_graph_api/client/users.rb
|
91
92
|
- lib/instagram_graph_api/version.rb
|
@@ -108,8 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
109
|
- !ruby/object:Gem::Version
|
109
110
|
version: '0'
|
110
111
|
requirements: []
|
111
|
-
|
112
|
-
rubygems_version: 2.7.7
|
112
|
+
rubygems_version: 3.0.6
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Instagram Graph API
|