gosns 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/gosns.gemspec +1 -1
- data/lib/gosns.rb +2 -0
- data/lib/provider/googleplus.rb +23 -0
- data/lib/provider/linkedin.rb +2 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f9d262edaac1006590aeef8e9d152f1f4431ab0
|
4
|
+
data.tar.gz: c1093218af1b681d537227fe08b1157e666f3704
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a0b3038a9167f1d368024f77af00e5365e30ecb1111727cc57a68a0f8268f35a52d6a5cc967f087448489897251346d7f3c66ce17c56f824a8b51c3a2fef0fb
|
7
|
+
data.tar.gz: f8c1dcbd3e7092fc60ade09724a9ac09c7259111388555d95511175662877d68f3c737f71e6d78c348ea31fc720fa9556a61b5cecfd4d2ed7c68a68777c34c73
|
data/gosns.gemspec
CHANGED
data/lib/gosns.rb
CHANGED
@@ -2,6 +2,7 @@ module Gosns
|
|
2
2
|
require 'nokogiri'
|
3
3
|
require 'open-uri'
|
4
4
|
require 'json'
|
5
|
+
require 'oauth2'
|
5
6
|
module Helper
|
6
7
|
class << self
|
7
8
|
def json(url)
|
@@ -41,4 +42,5 @@ module Gosns
|
|
41
42
|
require 'provider/twitter'
|
42
43
|
require 'provider/linkedin'
|
43
44
|
require 'provider/googleplus'
|
45
|
+
require 'provider/pinterest'
|
44
46
|
end
|
data/lib/provider/googleplus.rb
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
module Gosns
|
2
2
|
class Googleplus < Sns
|
3
|
+
class << self
|
4
|
+
attr_accessor :redirect_uri, :key, :secret
|
5
|
+
def oauth_authorize_url(options={})
|
6
|
+
oauth_client.auth_code.authorize_url(
|
7
|
+
redirect_uri: redirect_uri,
|
8
|
+
state: options[:state],
|
9
|
+
access_type: 'offline',
|
10
|
+
scope: 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/plus.login'
|
11
|
+
)
|
12
|
+
end
|
13
|
+
def oauth_client
|
14
|
+
option = {
|
15
|
+
site: 'https://accounts.google.com',
|
16
|
+
authorize_url: "/o/oauth2/auth",
|
17
|
+
token_url: "https://www.googleapis.com/oauth2/v3/token"
|
18
|
+
}
|
19
|
+
OAuth2::Client.new(key, secret, option)
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_token(code)
|
23
|
+
oauth_client.auth_code.get_token(code, redirect_uri: redirect_uri).token
|
24
|
+
end
|
25
|
+
end
|
3
26
|
def followers
|
4
27
|
Helper::parse_int Helper::at_css("https://plus.google.com/+#{account}", ".BOfSxb")
|
5
28
|
end
|
data/lib/provider/linkedin.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
module Gosns
|
2
2
|
class Linkedin < Sns
|
3
|
-
require 'oauth2'
|
4
3
|
class << self
|
5
4
|
attr_accessor :redirect_uri, :key, :secret
|
6
|
-
def oauth_authorize_url
|
7
|
-
state = 'DCEeFWf45A53sdfKef424'
|
5
|
+
def oauth_authorize_url(options={})
|
8
6
|
oauth_client.auth_code.authorize_url(
|
9
7
|
redirect_uri: redirect_uri,
|
10
|
-
state: state,
|
8
|
+
state: options[:state],
|
11
9
|
)
|
12
10
|
end
|
13
11
|
def oauth_client
|
@@ -25,7 +23,6 @@ module Gosns
|
|
25
23
|
end
|
26
24
|
|
27
25
|
def followers
|
28
|
-
JSON.parse(r.body)['followStatistics']['count']
|
29
26
|
Helper::parse_int Helper::at_css("https://www.linkedin.com/company/#{account}", '.followers-count')
|
30
27
|
end
|
31
28
|
end
|