gosns 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gosns.gemspec +2 -1
- data/lib/gosns.rb +1 -1
- data/lib/provider/linkedin.rb +25 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0848e3d314c60a6ba840341eeabe062194c8e464
|
4
|
+
data.tar.gz: 492f4738351be99761cecfb2613ea9257fe13a99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6376627bf000b76d8f4bc8d7c0028680ef7cc242e8875f6a94288a381ddca7e954a8243fb24639944f99636ef6add5f47cb5ba6b16c7af6db0176f711da0aa6
|
7
|
+
data.tar.gz: 402c4c2f5bfe08056fef70b15f7e11a2f9cbdbf903957ff715eb9411399c4612b5edcdd2c4f1e6a39dc914fa12fe1f1908661558b2cbaff19c4e0a0261e495de
|
data/gosns.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'gosns'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.2'
|
4
4
|
s.date = '2015-11-24'
|
5
5
|
s.summary = "gem sns information!"
|
6
6
|
s.description = "gem sns information from twitter, facebook, google+..."
|
@@ -11,4 +11,5 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.license = 'MIT'
|
12
12
|
|
13
13
|
s.add_runtime_dependency "nokogiri"
|
14
|
+
s.add_runtime_dependency "oauth2"
|
14
15
|
end
|
data/lib/gosns.rb
CHANGED
@@ -21,7 +21,7 @@ module Gosns
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def doc(url)
|
24
|
-
Nokogiri::HTML(open(url))
|
24
|
+
Nokogiri::HTML(open(url, 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36'))
|
25
25
|
end
|
26
26
|
|
27
27
|
def description(url)
|
data/lib/provider/linkedin.rb
CHANGED
@@ -1,6 +1,31 @@
|
|
1
1
|
module Gosns
|
2
2
|
class Linkedin < Sns
|
3
|
+
require 'oauth2'
|
4
|
+
class << self
|
5
|
+
attr_accessor :redirect_uri, :key, :secret
|
6
|
+
def oauth_authorize_url
|
7
|
+
state = 'DCEeFWf45A53sdfKef424'
|
8
|
+
oauth_client.auth_code.authorize_url(
|
9
|
+
redirect_uri: redirect_uri,
|
10
|
+
state: state,
|
11
|
+
)
|
12
|
+
end
|
13
|
+
def oauth_client
|
14
|
+
option = {
|
15
|
+
site: 'https://www.linkedin.com',
|
16
|
+
authorize_url: "/uas/oauth2/authorization",
|
17
|
+
token_url: "/uas/oauth2/accessToken"
|
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
|
26
|
+
|
3
27
|
def followers
|
28
|
+
JSON.parse(r.body)['followStatistics']['count']
|
4
29
|
Helper::parse_int Helper::at_css("https://www.linkedin.com/company/#{account}", '.followers-count')
|
5
30
|
end
|
6
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gosns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kikyous
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: oauth2
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: gem sns information from twitter, facebook, google+...
|
28
42
|
email: kikyous@163.com
|
29
43
|
executables: []
|