instaclient 0.0.2 → 0.0.3
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 +10 -1
- data/lib/instaclient.rb +0 -1
- data/lib/instaclient/client.rb +9 -0
- data/lib/instaclient/models/embed.rb +36 -0
- data/lib/instaclient/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d05f00211219cdd7bddaf3d632e01b93698b8e3
|
4
|
+
data.tar.gz: 254a0f9b161ede82cb8a67db5d7b09d5d58508b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5e04b7ebd44365312c523d38aabc6a96e780c9fd1a07889243fff6d6e52e8635911b6d2a82a57a67deed87b470cb9ebbefc50b2d10fbb93fee42b5cbf79de18
|
7
|
+
data.tar.gz: 137c8e97fcb9a27ac061ccffc5fbb38f99718d4e093185d71573cf3b84c4e43a3ea9aec35e106d513101a8aede3b49088c2a9b2ec3213da834b2f144c748383f
|
data/README.md
CHANGED
@@ -9,8 +9,8 @@ Usage
|
|
9
9
|
|
10
10
|
```
|
11
11
|
require 'instaclient'
|
12
|
-
|
13
12
|
client = Instaclient::Client.new(my_client_id, my_client_secret)
|
13
|
+
|
14
14
|
result = client.recent(user_id, count)
|
15
15
|
|
16
16
|
result.each do |media|
|
@@ -19,6 +19,15 @@ Usage
|
|
19
19
|
puts "Image: #{media.image_url(:standard_resolution)}"
|
20
20
|
...
|
21
21
|
end
|
22
|
+
|
23
|
+
embed = client.embed("https://instagram.com/p/somemedia/")
|
24
|
+
|
25
|
+
embed.html
|
26
|
+
#=> "<blockquote ..."
|
27
|
+
embed.title
|
28
|
+
#=> "media title"
|
29
|
+
embed.author
|
30
|
+
#=> "author name"
|
22
31
|
```
|
23
32
|
|
24
33
|
Methods
|
data/lib/instaclient.rb
CHANGED
data/lib/instaclient/client.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'typhoeus'
|
3
|
+
require 'instaclient/models/media'
|
4
|
+
require 'instaclient/models/embed'
|
3
5
|
|
4
6
|
module Instaclient
|
5
7
|
class Client
|
@@ -19,9 +21,16 @@ module Instaclient
|
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
24
|
+
def embed(media_url)
|
25
|
+
url = EMBED_ENDPOINT % { url: media_url }
|
26
|
+
data = parsed_response(url)
|
27
|
+
Models::Embed.new(data)
|
28
|
+
end
|
29
|
+
|
22
30
|
private
|
23
31
|
|
24
32
|
RECENT_MEDIA_ENDPOINT = "https://api.instagram.com/v1/users/%{user_id}/media/recent/?count=%{count}&client_id=%{client_id}"
|
33
|
+
EMBED_ENDPOINT = "http://api.instagram.com/oembed?url=%{url}"
|
25
34
|
|
26
35
|
def make_request(url)
|
27
36
|
Typhoeus.get(url).tap do |response|
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Instaclient
|
2
|
+
module Models
|
3
|
+
class Embed
|
4
|
+
attr_accessor :raw
|
5
|
+
|
6
|
+
def initialize(data)
|
7
|
+
@raw = data
|
8
|
+
end
|
9
|
+
|
10
|
+
def author_name
|
11
|
+
raw["author_name"]
|
12
|
+
end
|
13
|
+
|
14
|
+
def title
|
15
|
+
raw["title"]
|
16
|
+
end
|
17
|
+
|
18
|
+
def html
|
19
|
+
raw["html"]
|
20
|
+
end
|
21
|
+
|
22
|
+
def thumbnail
|
23
|
+
raw["thumbnail_url"]
|
24
|
+
end
|
25
|
+
|
26
|
+
def author_url
|
27
|
+
raw["author_url"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def author_id
|
31
|
+
raw["author_id"]
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/instaclient/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: instaclient
|
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
|
- Tiago Scolari
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- README.md
|
92
92
|
- lib/instaclient.rb
|
93
93
|
- lib/instaclient/client.rb
|
94
|
+
- lib/instaclient/models/embed.rb
|
94
95
|
- lib/instaclient/models/media.rb
|
95
96
|
- lib/instaclient/version.rb
|
96
97
|
homepage: https://github.com/tscolari/instaclient
|