insta-api 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +62 -18
- data/insta-api-0.1.0.gem +0 -0
- data/insta.gemspec +1 -1
- data/lib/insta.rb +1 -1
- data/lib/insta/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 398a2364b881d3a920967054ba95ea4b6e04a914515697aaad512fae17f7821b
|
4
|
+
data.tar.gz: 558514d258235e96a01abf3b759b5622c93b9712f6c2cf68a83353208d54d559
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a55759f7629926bd2e69884c5776f40b232f0644b1ba024979bbabfe44e53617ce565861b2f58ac17e9d5e3f5cfb32dda5dd24332e109212e8a60bd2ef00201
|
7
|
+
data.tar.gz: 9ce5c91b08bfb9e1c8a2794d5028daaa35d0537aaa6ec94e1f7bdfab1738b1821891a1684d2f4031bf1df080074c50ac73f935d08f8244befe734e067478b235
|
data/README.md
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
1
|
+
# Instagram
|
2
|
+
The [Instagram Basic Display API](https://developers.facebook.com/docs/instagram-basic-display-api) allows users of your app to get basic profile information, photos, and videos in their Instagram accounts.
|
3
|
+
The API can be used to access any type of Instagram account but only provides read-access to basic data.
|
6
4
|
|
5
|
+
## Source
|
6
|
+
- [Facebook developers docs](https://developers.facebook.com/docs/instagram-basic-display-api)
|
7
7
|
## Installation
|
8
8
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem 'insta'
|
12
|
+
gem 'insta-api'
|
13
13
|
```
|
14
14
|
|
15
15
|
And then execute:
|
@@ -18,27 +18,71 @@ And then execute:
|
|
18
18
|
|
19
19
|
Or install it yourself as:
|
20
20
|
|
21
|
-
$ gem install insta
|
21
|
+
$ gem install insta-api
|
22
22
|
|
23
|
-
## Usage
|
24
23
|
|
25
|
-
|
24
|
+
## Usage
|
25
|
+
##### Step 1: Authorization Window URL
|
26
|
+
Construct the Authorization Window URL below, replacing {app-id} with your Instagram app’s ID (from the App `Dashboard > Products > Instagram > Basic Display > Instagram App ID field`), replacing {app-secret} with your Instagram app’s ID (from the App `Dashboard > Products > Instagram > Basic Display > Instagram App Secret`) and {redirect-uri} with your website URL that you provided in Step 2 (`Valid OAuth Redirect URIs`). The URL must be exactly the same.
|
27
|
+
```sh
|
28
|
+
> require 'insta'
|
29
|
+
> options = { redirect_uri: `redirect-uri`, client_id: `app-id`, client_secret: `app-secret` }
|
30
|
+
> client = Insta::Client.new(options)
|
31
|
+
> client.auth_url
|
32
|
+
# output:
|
33
|
+
# https://api.instagram.com/oauth/authorize?client_id=#{client_id}&redirect_uri=#{redirect_uri}&scope=#{scope}&response_type=code
|
34
|
+
```
|
35
|
+
Authenticate your Instagram user by signing into the Authorization Window, then click Authorize to grant your app access to your profile data. Upon success, the page will redirect you to the redirect URI you included in the previous step and append an Authorization Code. For example:
|
26
36
|
|
27
|
-
|
37
|
+
`https://socialsizzle.herokuapp.com/auth/?code=AQDp3TtBQQ...#_`
|
28
38
|
|
29
|
-
|
39
|
+
Note that `#_` has been appended to the end of the redirect URI, but it is not part of the `code` itself. Copy the code (without the `#_` portion) so you can use it in the next step.
|
30
40
|
|
31
|
-
|
41
|
+
##### Step 2: Exchange the Code for a Token
|
42
|
+
code => ....auth/?`code=AQDp3TtBQQ...`#_
|
43
|
+
```sh
|
44
|
+
> client.access_token(code)
|
45
|
+
# output:
|
46
|
+
# {
|
47
|
+
# "access_token": "IGQVJ...",
|
48
|
+
# "user_id": 17841405793187218
|
49
|
+
# }
|
50
|
+
```
|
51
|
+
##### Step 3: Exchange a short-lived Instagram User Access Token for a long-lived Instagram User Access Token.
|
52
|
+
long-lived valid only 60day
|
53
|
+
```sh
|
54
|
+
> access_token = "IGQVJ..."
|
55
|
+
> client.long_lived_access_token(access_token)
|
56
|
+
# output:
|
57
|
+
# {
|
58
|
+
# "access_token": "{access-token}",
|
59
|
+
# "token_type": "{token-type}",
|
60
|
+
# "expires_in": {expires-in}
|
61
|
+
# }
|
62
|
+
```
|
32
63
|
|
33
|
-
|
64
|
+
##### Step 4: User Info, Media Data
|
34
65
|
|
35
|
-
|
66
|
+
- create new client
|
67
|
+
```sh
|
68
|
+
> require 'insta'
|
69
|
+
> access_token = "IGQVJ..."
|
70
|
+
> client = Insta::API.new(access_token)
|
71
|
+
```
|
72
|
+
- user info
|
73
|
+
```sh
|
74
|
+
> client.me
|
75
|
+
```
|
76
|
+
- user media
|
77
|
+
```sh
|
78
|
+
> client.media
|
79
|
+
> # or
|
80
|
+
> client.media(25)
|
81
|
+
> # for pagination after above method call, run below method for getting next 25 media
|
82
|
+
> client.next_page
|
83
|
+
```
|
36
84
|
|
37
85
|
|
38
86
|
## License
|
39
87
|
|
40
88
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
|
-
|
42
|
-
## Code of Conduct
|
43
|
-
|
44
|
-
Everyone interacting in the Insta project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/insta/blob/master/CODE_OF_CONDUCT.md).
|
data/insta-api-0.1.0.gem
ADDED
Binary file
|
data/insta.gemspec
CHANGED
@@ -11,6 +11,6 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
12
12
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
13
13
|
end
|
14
|
-
s.homepage = 'https://
|
14
|
+
s.homepage = 'https://github.com/shubhamprajapat1/instagram'
|
15
15
|
s.metadata = { "source_code_uri" => "https://github.com/shubhamprajapat1/instagram" }
|
16
16
|
end
|
data/lib/insta.rb
CHANGED
@@ -69,7 +69,7 @@ module Insta
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def media(limit = 100)
|
72
|
-
url = "https://graph.instagram.com/me/media?fields=id,media_type,media_url,username,timestamp&access_token=#{access_token}&limit=#{limit}"
|
72
|
+
url = "https://graph.instagram.com/me/media?fields=id,media_type,caption,permalink,thumbnail_url,media_url,username,timestamp&access_token=#{access_token}&limit=#{limit}"
|
73
73
|
response = get(url)
|
74
74
|
puts response.dig('paging', 'next')
|
75
75
|
@next_url = response.dig('paging', 'next') unless response.dig('paging', 'next').nil?
|
data/lib/insta/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: insta-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shubham Prajapat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: The Instagram Basic Display API allows users of your app to get basic
|
14
14
|
profile information, photos, and videos in their Instagram accounts.
|
@@ -25,10 +25,11 @@ files:
|
|
25
25
|
- bin/console
|
26
26
|
- bin/setup
|
27
27
|
- insta-0.1.0.gem
|
28
|
+
- insta-api-0.1.0.gem
|
28
29
|
- insta.gemspec
|
29
30
|
- lib/insta.rb
|
30
31
|
- lib/insta/version.rb
|
31
|
-
homepage: https://
|
32
|
+
homepage: https://github.com/shubhamprajapat1/instagram
|
32
33
|
licenses:
|
33
34
|
- MIT
|
34
35
|
metadata:
|