wechat-sns 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/wechat/sns/access_token.rb +2 -2
- data/lib/wechat/sns/user_profile.rb +37 -0
- data/lib/wechat/sns/version.rb +1 -1
- data/lib/wechat/sns.rb +1 -1
- data/wechat-sns.gemspec +4 -2
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8241ec82a3b4c5bc58fa6cef8d01460b8dc8cfe1
|
4
|
+
data.tar.gz: 979479374d24ec788f4e6072dce4642bedd43ea0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 627cd9f16ec99f45e6cd067302d0214f48e29f83bf61b788a30eff2fd70f1364d727f11b29b1e43ed88be128bf4306b1ab951291c91814e4e4c14cb721c932b0
|
7
|
+
data.tar.gz: c56980daf80df6ed17d8e3c9adce03c3ecbc34745674366065aea8117d6b10137d404719ce587c2dfe673d94bf401be6c95aebd213ae1b8ea954eb399e17cdd3
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'jsonclient'
|
2
2
|
|
3
|
-
class Wechat::
|
3
|
+
class Wechat::SNS::AccessToken
|
4
4
|
|
5
|
-
|
5
|
+
include ::Wechat::Core::Common
|
6
6
|
|
7
7
|
# 附:检验授权凭证(access_token)是否有效
|
8
8
|
# http://mp.weixin.qq.com/wiki/9/01f711493b5a02f24b04365ac5d8fd95.html#.E9.99.84.EF.BC.9A.E6.A3.80.E9.AA.8C.E6.8E.88.E6.9D.83.E5.87.AD.E8.AF.81.EF.BC.88access_token.EF.BC.89.E6.98.AF.E5.90.A6.E6.9C.89.E6.95.88
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'jsonclient'
|
2
|
+
|
3
|
+
class Wechat::SNS::UserProfile
|
4
|
+
|
5
|
+
# 第四步:拉取用户信息(需scope为 snsapi_userinfo)
|
6
|
+
# http://mp.weixin.qq.com/wiki/9/01f711493b5a02f24b04365ac5d8fd95.html#.E7.AC.AC.E5.9B.9B.E6.AD.A5.EF.BC.9A.E6.8B.89.E5.8F.96.E7.94.A8.E6.88.B7.E4.BF.A1.E6.81.AF.28.E9.9C.80scope.E4.B8.BA_snsapi_userinfo.29
|
7
|
+
#
|
8
|
+
# Return hash format if success:
|
9
|
+
# {
|
10
|
+
# openid: <OPEN_ID>,
|
11
|
+
# nickname: <NICK_NAME>,
|
12
|
+
# sex: <GENDER_CODE>, # 用户的性别,值为1时是男性,值为2时是女性,值为0时是未知
|
13
|
+
# city: <CITY_NAME>, # 普通用户个人资料填写的城市
|
14
|
+
# province: <PROVINCE_NAME>, # 用户个人资料填写的省份
|
15
|
+
# country: <COUNTRY_NAME>, # 国家,如中国为CN
|
16
|
+
# headimgurl: <HEAD_IMAGE_LINK>, # 用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空。若用户更换头像,原有头像URL将失效。
|
17
|
+
# privilege: [ <PRIVILEGE_1>, <PRIVILEGE_2>, ... ], # 用户特权信息,json 数组,如微信沃卡用户为(chinaunicom)
|
18
|
+
# unionid: <UNION_ID> # 只有在用户将公众号绑定到微信开放平台帐号后,才会出现该字段。
|
19
|
+
# }
|
20
|
+
#
|
21
|
+
# Return hash format if failure:
|
22
|
+
# {
|
23
|
+
# errcode: <ERROR_CODE>,
|
24
|
+
# errmsg: <ERROR_MESSAGE>
|
25
|
+
# }
|
26
|
+
def self.load(access_token, open_id, language = Wechat::Core::Common::LANGUAGE_SIMPLIFIED_CHINESE)
|
27
|
+
message = ::JSONClient.new.get 'https://api.weixin.qq.com/sns/userinfo',
|
28
|
+
{
|
29
|
+
access_token: access_token,
|
30
|
+
openid: open_id,
|
31
|
+
lang: language
|
32
|
+
}
|
33
|
+
body = message.body
|
34
|
+
body.is_a?(Hash) ? body : JSON.parse(body)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/lib/wechat/sns/version.rb
CHANGED
data/lib/wechat/sns.rb
CHANGED
data/wechat-sns.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = [ 'Topbit Du' ]
|
10
10
|
spec.email = [ 'topbit.du@gmail.com' ]
|
11
11
|
|
12
|
-
spec.summary = %q{Wechat SNS Library}
|
13
|
-
spec.description = %q{
|
12
|
+
spec.summary = %q{Wechat SNS Library 微信社交库}
|
13
|
+
spec.description = %q{Wechat SNS Library is a wrapper for calling Wechat SNS APIs. 微信社交库封装了对微信社交API的调用。}
|
14
14
|
spec.homepage = 'https://github.com/topbitdu/wechat-sns'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
@@ -31,4 +31,6 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_development_dependency 'rake', '~> 10.0'
|
32
32
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
33
|
|
34
|
+
spec.add_dependency 'wechat-core', '~> 0.2'
|
35
|
+
|
34
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wechat-sns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,7 +52,21 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: wechat-core
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.2'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.2'
|
69
|
+
description: Wechat SNS Library is a wrapper for calling Wechat SNS APIs. 微信社交库封装了对微信社交API的调用。
|
56
70
|
email:
|
57
71
|
- topbit.du@gmail.com
|
58
72
|
executables: []
|
@@ -74,6 +88,7 @@ files:
|
|
74
88
|
- lib/wechat/sns.rb
|
75
89
|
- lib/wechat/sns/access_token.rb
|
76
90
|
- lib/wechat/sns/authorize_link.rb
|
91
|
+
- lib/wechat/sns/user_profile.rb
|
77
92
|
- lib/wechat/sns/version.rb
|
78
93
|
- wechat-sns.gemspec
|
79
94
|
homepage: https://github.com/topbitdu/wechat-sns
|
@@ -99,5 +114,5 @@ rubyforge_project:
|
|
99
114
|
rubygems_version: 2.4.5.1
|
100
115
|
signing_key:
|
101
116
|
specification_version: 4
|
102
|
-
summary: Wechat SNS Library
|
117
|
+
summary: Wechat SNS Library 微信社交库
|
103
118
|
test_files: []
|