instagram_graph_api 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/bin/console +2 -5
- data/lib/instagram_graph_api/client/media.rb +41 -4
- data/lib/instagram_graph_api/client/users.rb +1 -1
- data/lib/instagram_graph_api/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 28320da8d9ba8e5b0c16cf85f204d282b73766edf1f2c0614becaa87eee9394d
|
4
|
+
data.tar.gz: b24c8987eef0aeb5f97ca77001e450c9b9b110b26c7ea72df00488eb45a81532
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93804d5de94409db1fe636bd58b7e0960bec82af3ca9b01872d85d06761d2a58d2e19864e762307d748cf790c38ff35a53e0d8c663c70ebc299e58d6550f071a
|
7
|
+
data.tar.gz: 0a5df44c8e045521b81069c6ac80cf9d2a2b1618b41d9fdc9c0dfce00616603227a3323c854204c804bab11d126dee3b5cb73868b25918067bbeb918d3871753
|
data/bin/console
CHANGED
@@ -7,8 +7,5 @@ require "instagram_graph_api"
|
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
9
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
10
|
+
require "pry"
|
11
|
+
Pry.start
|
@@ -1,11 +1,29 @@
|
|
1
1
|
module InstagramGraphApi
|
2
2
|
class Client
|
3
3
|
module Media
|
4
|
-
|
5
|
-
|
4
|
+
attr_accessor :media_info, :insights
|
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
|
+
MEDIA_INFO_HASH = {
|
13
|
+
image: "comments_count,like_count,media_type,"\
|
14
|
+
"media_url,permalink,timestamp,thumbnail_url",
|
15
|
+
video: "comments_count,like_count,media_type,"\
|
16
|
+
"media_url,permalink,timestamp,thumbnail_url",
|
17
|
+
story: "media_type,media_url,permalink,"\
|
18
|
+
"timestamp,thumbnail_url"
|
19
|
+
}
|
20
|
+
|
21
|
+
def get_user_recent_media(id, type: "image", options: {})
|
22
|
+
entity = type.eql?("story") ? "stories" : "media"
|
23
|
+
query = "#{entity}?fields=#{MEDIA_INFO_HASH[type.to_sym]}"
|
6
24
|
query += "&after=#{options[:after]}" if options[:after]
|
7
|
-
query += "&
|
8
|
-
get_connections(
|
25
|
+
query += "&before=#{options[:before]}" if options[:before]
|
26
|
+
get_connections(id, query)
|
9
27
|
end
|
10
28
|
|
11
29
|
def get_media_details(media_id, fields = nil)
|
@@ -13,6 +31,25 @@ module InstagramGraphApi
|
|
13
31
|
media_url,permalink,timestamp,thumbnail_url,ig_id"
|
14
32
|
get_connections(media_id , "?fields=#{fields}")
|
15
33
|
end
|
34
|
+
|
35
|
+
def insight(media_id, type)
|
36
|
+
insights = get_insights(media_id)
|
37
|
+
if insights
|
38
|
+
insight = insights.select{|m| m["name"] == type}.first
|
39
|
+
data = if insight
|
40
|
+
insight
|
41
|
+
else
|
42
|
+
try(type).first
|
43
|
+
end
|
44
|
+
|
45
|
+
data["values"].first["value"]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
def get_insights(media_id)
|
51
|
+
@insights = get_connections(media_id , "insights?metric=#{METRIC_HASH[type.to_sym]}")
|
52
|
+
end
|
16
53
|
end
|
17
54
|
end
|
18
55
|
end
|
@@ -2,7 +2,7 @@ module InstagramGraphApi
|
|
2
2
|
class Client
|
3
3
|
module Users
|
4
4
|
def ig_business_accounts(fields = nil)
|
5
|
-
fields ||= 'id,name,biography,
|
5
|
+
fields ||= 'id,name,biography,ig_id,followers_count,profile_picture_url,username'
|
6
6
|
accounts = get_pages("?fields=instagram_business_account{#{fields}}")
|
7
7
|
accounts.map do |a|
|
8
8
|
a["instagram_business_account"].merge(page_id: a["id"]) if a["instagram_business_account"]
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rakesh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
98
|
+
rubygems_version: 2.7.7
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: Instagram Graph API
|