instagram_graph_api 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +70 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/instagram_graph_api.gemspec +38 -0
- data/lib/instagram_graph_api.rb +9 -0
- data/lib/instagram_graph_api/client.rb +15 -0
- data/lib/instagram_graph_api/client/discovery.rb +20 -0
- data/lib/instagram_graph_api/client/media.rb +18 -0
- data/lib/instagram_graph_api/client/users.rb +33 -0
- data/lib/instagram_graph_api/version.rb +3 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c146673cee7d9aa329292c2960179c110769dea3
|
4
|
+
data.tar.gz: e32f237195aba30a370cef2f4325f8f71648ceda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9707fccfeffa43462d11236ea251f7de3491a21bdae65a8b4f40417b6d5f0d300446586f0f8ad4710b47be7cd207c78a25e71d8a4ce8bfbbc7803be8f60b3ead
|
7
|
+
data.tar.gz: 0a6b45183ee0c6da248a264a656a93f76a577c30e4fe6417a625be99805f02baf3a06e0c305c3eb7a3b9a03809cd88e3181f24a9306f059bc10299a6b70c470b
|
data/.gitignore
ADDED
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,70 @@
|
|
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
|
+
|
29
|
+
#get IG business account info
|
30
|
+
client.get_account_info(IG_BUSINESS_ID)
|
31
|
+
#to get specific fields
|
32
|
+
fields = "name, biography"
|
33
|
+
client.get_account_info(IG_BUSINESS_ID, fields)
|
34
|
+
|
35
|
+
#get media list
|
36
|
+
client.get_user_recent_media(IG_BUSINESS_ID)
|
37
|
+
|
38
|
+
#get media details
|
39
|
+
client.get_media_details(MEDIA_ID)
|
40
|
+
#to get specific fields
|
41
|
+
fields = "media_url, permalink"
|
42
|
+
client.get_media_details(MEDIA_ID, fields)
|
43
|
+
|
44
|
+
#Discover business user
|
45
|
+
client.discover_user(USERNAME)
|
46
|
+
# fields can be from "id,followers_count,media_count,ig_id"
|
47
|
+
fields = "followers_count,media_count,ig_id"
|
48
|
+
client.discover_user(USERNAME, fields)
|
49
|
+
|
50
|
+
#discover user media, fields can be "caption,media_url,media_type,like_count,comments_count,id"
|
51
|
+
client.discover_user_media(USERNAME, fields)
|
52
|
+
```
|
53
|
+
|
54
|
+
## Development
|
55
|
+
|
56
|
+
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.
|
57
|
+
|
58
|
+
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).
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
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.
|
63
|
+
|
64
|
+
## License
|
65
|
+
|
66
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
67
|
+
|
68
|
+
## Code of Conduct
|
69
|
+
|
70
|
+
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,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "instagram_graph_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
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "instagram_graph_api/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "instagram_graph_api"
|
8
|
+
spec.version = InstagramGraphApi::VERSION
|
9
|
+
spec.authors = ["Rakesh"]
|
10
|
+
spec.email = ["rakesh.patra93@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Instagram Graph API}
|
13
|
+
spec.description = %q{New Instagram Graph API}
|
14
|
+
spec.homepage = "https://github.com/rakeshpatra/instagram_graph_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", "~> 10.0"
|
37
|
+
spec.add_dependency "koala"
|
38
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'koala'
|
2
|
+
|
3
|
+
module InstagramGraphApi
|
4
|
+
class Client < Koala::Facebook::API
|
5
|
+
Dir[File.expand_path('../client/*.rb', __FILE__)].each{|f| require f}
|
6
|
+
|
7
|
+
include InstagramGraphApi::Client::Users
|
8
|
+
include InstagramGraphApi::Client::Media
|
9
|
+
include InstagramGraphApi::Client::Discovery
|
10
|
+
|
11
|
+
def initialize(media_id = nil, access_token)
|
12
|
+
super(access_token)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module InstagramGraphApi
|
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)
|
15
|
+
fields ||= "caption,media_url,media_type,like_count,comments_count,id"
|
16
|
+
discover_user(username, "media{#{fields}}")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module InstagramGraphApi
|
2
|
+
class Client
|
3
|
+
module Media
|
4
|
+
def get_user_recent_media(ig_account_id, type: "media", options: {})
|
5
|
+
query = "#{type}?fields=comments_count,like_count,media_type,media_url,permalink,timestamp,thumbnail_url"
|
6
|
+
query += "&after=#{options[:after]}" if options[:after]
|
7
|
+
query += "&after=#{options[:before]}" if options[:before]
|
8
|
+
get_connections(ig_account_id, query)
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_media_details(media_id, fields = nil)
|
12
|
+
fields ||= "comments_count,like_count,media_type,
|
13
|
+
media_url,permalink,timestamp,thumbnail_url,ig_id"
|
14
|
+
get_connections(media_id , "?fields=#{fields}")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module InstagramGraphApi
|
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 get_account_info(ig_account_id, fields = nil)
|
13
|
+
fields ||= "biography,followers_count,ig_id,name,profile_picture_url,username,id"
|
14
|
+
get_connections(ig_account_id , "?fields=#{fields}")
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def get_pages(params="")
|
20
|
+
begin
|
21
|
+
get_connections('me', "accounts#{params}")
|
22
|
+
rescue Exception => e
|
23
|
+
puts e.message
|
24
|
+
[]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_business_account_id
|
29
|
+
ig_business_accounts.first.dig('id')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rakesh
|
@@ -58,7 +58,23 @@ email:
|
|
58
58
|
executables: []
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
|
-
files:
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- CODE_OF_CONDUCT.md
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- instagram_graph_api.gemspec
|
72
|
+
- lib/instagram_graph_api.rb
|
73
|
+
- lib/instagram_graph_api/client.rb
|
74
|
+
- lib/instagram_graph_api/client/discovery.rb
|
75
|
+
- lib/instagram_graph_api/client/media.rb
|
76
|
+
- lib/instagram_graph_api/client/users.rb
|
77
|
+
- lib/instagram_graph_api/version.rb
|
62
78
|
homepage: https://github.com/rakeshpatra/instagram_graph_api
|
63
79
|
licenses:
|
64
80
|
- MIT
|