bundl_instagram_api 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +56 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +86 -0
- data/Rakefile +2 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/bundl_instagram_api.gemspec +39 -0
- data/lib/bundl_instagram_api/client/discovery.rb +22 -0
- data/lib/bundl_instagram_api/client/insights.rb +30 -0
- data/lib/bundl_instagram_api/client/media.rb +31 -0
- data/lib/bundl_instagram_api/client/tag.rb +21 -0
- data/lib/bundl_instagram_api/client/users.rb +41 -0
- data/lib/bundl_instagram_api/client.rb +13 -0
- data/lib/bundl_instagram_api/version.rb +3 -0
- data/lib/bundl_instagram_api.rb +9 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a3f23a75d61a18e52ea5a321dcfa0be0b3fe49d57703fa74f8add56bc3d2e0d3
|
4
|
+
data.tar.gz: 504f3f7d0957352958aa4da4d31908797f516de3eee4a4fbe3e6115863439f37
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e292358f69e7c4106d874c03834a85035816927a09a8699e451005ee5b2fecbd0dcc4319789c7c0e0442fb13aedaf719bb02a51bd5dfbc468dc581979afb72f2
|
7
|
+
data.tar.gz: f6f1f738194e9e949b1d9c11a76b18fff445f9a77a879fc59c96b0aae6e9a5dfb9687abb92200b6fb545cb27070c7417887cfa60f12036658fcf875bb6185502
|
data/.gitignore
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
# Ignore Byebug command history file.
|
17
|
+
.byebug_history
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
# Gemfile.lock
|
49
|
+
# .ruby-version
|
50
|
+
# .ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
54
|
+
|
55
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
56
|
+
# .rubocop-https?--*
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at rakesh.patra@mindfiresolutions.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Rakesh kumar Patra
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 TODO: Write your name
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# InstagramGraphApi
|
2
|
+
|
3
|
+
A gem for Instagram Graph API using [koala](https://github.com/arsduo/koala).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'instagram_graph_api'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install instagram_graph_api
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
client = InstagramGraphApi.client(ACCESS_TOKEN)
|
25
|
+
|
26
|
+
#get an arraay of business accounts linked to the access_token
|
27
|
+
client.ig_business_accounts
|
28
|
+
#get an array of connected IG accounts linked to the access_token
|
29
|
+
client.connected_ig_accounts
|
30
|
+
|
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
|
36
|
+
client.get_account_info(IG_BUSINESS_ID)
|
37
|
+
#to get specific fields
|
38
|
+
fields = "name, biography"
|
39
|
+
client.get_account_info(IG_BUSINESS_ID, fields)
|
40
|
+
|
41
|
+
#get media list
|
42
|
+
client.get_user_recent_media(IG_BUSINESS_ID)
|
43
|
+
|
44
|
+
#get media details
|
45
|
+
client.get_media_details(MEDIA_ID)
|
46
|
+
#to get specific fields
|
47
|
+
fields = "media_url, permalink"
|
48
|
+
client.get_media_details(MEDIA_ID, fields)
|
49
|
+
|
50
|
+
#Discover business user
|
51
|
+
client.discover_user(USERNAME)
|
52
|
+
# fields can be from "id,followers_count,media_count,ig_id"
|
53
|
+
fields = "followers_count,media_count,ig_id"
|
54
|
+
client.discover_user(USERNAME, fields)
|
55
|
+
|
56
|
+
#discover user media, fields can be "caption,media_url,media_type,like_count,comments_count,id"
|
57
|
+
client.discover_user_media(USERNAME, fields)
|
58
|
+
|
59
|
+
#Search for a tag,
|
60
|
+
client.tag_media(page_token, tag_name)
|
61
|
+
#fields can be "media_type,comments_count,like_count,media_url,permalink"
|
62
|
+
fields="media_url,permalink"
|
63
|
+
client.tag_media(page_token, tag_name, fields)
|
64
|
+
#custom edge can be provided, default is 'top_media'
|
65
|
+
tag_media = client.tag_media(page_token, tag_name, edge: "recent_media")
|
66
|
+
# Note: We can run `tag_media.next_page` to fetch next set of results
|
67
|
+
# additional arguent options can also be passed for page params i.e before/after/limit etc
|
68
|
+
```
|
69
|
+
|
70
|
+
## Development
|
71
|
+
|
72
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
73
|
+
|
74
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
75
|
+
|
76
|
+
## Contributing
|
77
|
+
|
78
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rakeshpatra/instagram_graph_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
79
|
+
|
80
|
+
## License
|
81
|
+
|
82
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
83
|
+
|
84
|
+
## Code of Conduct
|
85
|
+
|
86
|
+
Everyone interacting in the InstagramGraphApi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rakeshpatra/instagram_graph_api/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "bundl_instagram_api"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
require "pry"
|
11
|
+
Pry.start
|
data/bin/setup
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "bundl_instagram_api/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bundl_instagram_api"
|
8
|
+
spec.version = BundlInstagramApi::VERSION
|
9
|
+
spec.authors = ["Tyler"]
|
10
|
+
spec.email = ["tyler@trybundl.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Bundl's Instagram Graph API}
|
13
|
+
spec.description = %q{New Instagram Graph API}
|
14
|
+
spec.homepage = "https://github.com/tameyer41/bundl_instagram-api"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
# "public gem pushes."
|
24
|
+
# end
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
+
end
|
31
|
+
spec.bindir = "exe"
|
32
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ["lib"]
|
34
|
+
|
35
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
36
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
37
|
+
spec.add_development_dependency "pry"
|
38
|
+
spec.add_dependency "koala"
|
39
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module BundlInstagramApi
|
2
|
+
class Client
|
3
|
+
module Discovery
|
4
|
+
def discover_user(username, fields = nil)
|
5
|
+
fields ||= "id,followers_count,media_count,ig_id"
|
6
|
+
bg_id = get_business_account_id
|
7
|
+
raise "No business-account found, you need to have atleast one IG business-account" unless bg_id
|
8
|
+
query = "?fields=business_discovery.username(#{username}){#{fields}}"
|
9
|
+
get_connections(bg_id, query)
|
10
|
+
rescue Exception => e
|
11
|
+
puts e.message
|
12
|
+
end
|
13
|
+
|
14
|
+
def discover_user_media(username, fields = nil, options={})
|
15
|
+
fields ||= "caption,media_url,media_type,like_count,comments_count,id"
|
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}}")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module BundlInstagramApi
|
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
|
+
|
20
|
+
def user_insights(object_id, metrics: nil, period:nil)
|
21
|
+
@raw_insights = get_connections(object_id, "insights?metric=#{metrics}&period=#{period}")
|
22
|
+
@raw_insights.reduce({}) do |result, insight_data|
|
23
|
+
result[insight_data["name"]] = insight_data["values"].first["value"]
|
24
|
+
result
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module BundlInstagramApi
|
2
|
+
class Client
|
3
|
+
module Media
|
4
|
+
attr_accessor :media_info, :raw_insights
|
5
|
+
|
6
|
+
MEDIA_INFO_HASH = {
|
7
|
+
image: "comments_count,like_count,media_type,"\
|
8
|
+
"media_url,permalink,timestamp,thumbnail_url",
|
9
|
+
video: "comments_count,like_count,media_type,"\
|
10
|
+
"media_url,permalink,timestamp,thumbnail_url",
|
11
|
+
story: "media_type,media_url,permalink,"\
|
12
|
+
"timestamp,thumbnail_url"
|
13
|
+
}
|
14
|
+
|
15
|
+
def get_user_recent_media(id, fields = nil, type: "image", options: {})
|
16
|
+
entity = type.eql?("story") ? "stories" : "media"
|
17
|
+
fields ||= MEDIA_INFO_HASH[type.to_sym]
|
18
|
+
query = "#{entity}?fields=#{fields}"
|
19
|
+
query += "&after=#{options[:after]}" if options[:after]
|
20
|
+
query += "&before=#{options[:before]}" if options[:before]
|
21
|
+
get_connections(id, query)
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_media_details(media_id, fields = nil, type: "image")
|
25
|
+
fields ||= MEDIA_INFO_HASH[type.to_sym]
|
26
|
+
get_connections(media_id , "?fields=#{fields}")
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module BundlInstagramApi
|
2
|
+
class Client
|
3
|
+
module Tag
|
4
|
+
def tag_media(page_token, tag_name, fields = nil, edge: "top_media", options: {})
|
5
|
+
user_id = get_ig_id_from_token(page_token)
|
6
|
+
tag_info = graph_call("ig_hashtag_search?user_id=#{user_id}&q=#{tag_name}")[0]
|
7
|
+
fields ||= "id,media_type,comments_count,like_count,media_url,permalink"
|
8
|
+
query = "#{edge}?user_id=#{user_id}&fields=#{fields}"
|
9
|
+
query += options.reduce(""){|s, (k, v)| s+= "&#{k}=#{v}" }
|
10
|
+
get_connections(tag_info["id"], query)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def get_ig_id_from_token(token)
|
16
|
+
account_info = get_connections('me', "?fields=connected_instagram_account")
|
17
|
+
account_info.dig("connected_instagram_account", "id")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module BundlInstagramApi
|
2
|
+
class Client
|
3
|
+
module Users
|
4
|
+
def ig_business_accounts(fields = nil)
|
5
|
+
fields ||= 'id,name,biography,ig_id,followers_count,profile_picture_url,username'
|
6
|
+
accounts = get_pages("?fields=instagram_business_account{#{fields}}")
|
7
|
+
accounts.map do |a|
|
8
|
+
a["instagram_business_account"].merge(page_id: a["id"]) if a["instagram_business_account"]
|
9
|
+
end.compact
|
10
|
+
end
|
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
|
+
|
20
|
+
def get_account_info(ig_account_id, fields = nil)
|
21
|
+
fields ||= "biography,followers_count,ig_id,name,profile_picture_url,username,id"
|
22
|
+
get_connections(ig_account_id , "?fields=#{fields}")
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def get_pages(params="")
|
28
|
+
begin
|
29
|
+
get_connections('me', "accounts#{params}")
|
30
|
+
rescue Exception => e
|
31
|
+
puts e.message
|
32
|
+
[]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_business_account_id
|
37
|
+
ig_business_accounts.first.dig('id')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'koala'
|
2
|
+
|
3
|
+
module BundlInstagramApi
|
4
|
+
class Client < Koala::Facebook::API
|
5
|
+
Dir[File.expand_path('../client/*.rb', __FILE__)].each{|f| require f}
|
6
|
+
|
7
|
+
include BundlInstagramApi::Client::Insights
|
8
|
+
include BundlInstagramApi::Client::Users
|
9
|
+
include BundlInstagramApi::Client::Media
|
10
|
+
include BundlInstagramApi::Client::Discovery
|
11
|
+
include BundlInstagramApi::Client::Tag
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bundl_instagram_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tyler
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-11-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 12.3.3
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 12.3.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: koala
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: New Instagram Graph API
|
70
|
+
email:
|
71
|
+
- tyler@trybundl.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- CODE_OF_CONDUCT.md
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- bundl_instagram_api.gemspec
|
86
|
+
- lib/bundl_instagram_api.rb
|
87
|
+
- lib/bundl_instagram_api/client.rb
|
88
|
+
- lib/bundl_instagram_api/client/discovery.rb
|
89
|
+
- lib/bundl_instagram_api/client/insights.rb
|
90
|
+
- lib/bundl_instagram_api/client/media.rb
|
91
|
+
- lib/bundl_instagram_api/client/tag.rb
|
92
|
+
- lib/bundl_instagram_api/client/users.rb
|
93
|
+
- lib/bundl_instagram_api/version.rb
|
94
|
+
homepage: https://github.com/tameyer41/bundl_instagram-api
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubygems_version: 3.2.3
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: Bundl's Instagram Graph API
|
117
|
+
test_files: []
|