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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 817bc9e37b53da18d09d6ed8059f942d0ed12304
4
- data.tar.gz: 3673d1853612b67a358a28f6793a9f83759a00d1
3
+ metadata.gz: 8241ec82a3b4c5bc58fa6cef8d01460b8dc8cfe1
4
+ data.tar.gz: 979479374d24ec788f4e6072dce4642bedd43ea0
5
5
  SHA512:
6
- metadata.gz: ae656236312fdbdac777cd74d66900b885ae90f8296b2e462750e9b16c06dc01e786d0b76610a59265e0ce0b711b65e45b9110ed61ab2298cf1682ba25532f11
7
- data.tar.gz: 25a9067f4c23d44dad19b261f7d253400e416e8ec8d767d242be7522fdbcb3d161ba3e7426c9250d3703e0b4513af248505ef1d4f2982562c13a625c4b61a61c
6
+ metadata.gz: 627cd9f16ec99f45e6cd067302d0214f48e29f83bf61b788a30eff2fd70f1364d727f11b29b1e43ed88be128bf4306b1ab951291c91814e4e4c14cb721c932b0
7
+ data.tar.gz: c56980daf80df6ed17d8e3c9adce03c3ecbc34745674366065aea8117d6b10137d404719ce587c2dfe673d94bf401be6c95aebd213ae1b8ea954eb399e17cdd3
data/CHANGELOG.md CHANGED
@@ -5,3 +5,6 @@
5
5
 
6
6
  ## v0.2
7
7
  1. Access Token wrapper class.
8
+
9
+ ## v0.3
10
+ 1. User Profile wrapper class.
@@ -1,8 +1,8 @@
1
1
  require 'jsonclient'
2
2
 
3
- class Wechat::Sns::AccessToken
3
+ class Wechat::SNS::AccessToken
4
4
 
5
- extend ::Wechat::Common
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
@@ -1,5 +1,5 @@
1
1
  module Wechat
2
2
  module SNS
3
- VERSION = '0.2'.freeze
3
+ VERSION = '0.3'.freeze
4
4
  end
5
5
  end
data/lib/wechat/sns.rb CHANGED
@@ -2,9 +2,9 @@ require 'wechat/sns/version'
2
2
 
3
3
  require 'wechat/sns/authorize_link'
4
4
  require 'wechat/sns/access_token'
5
+ require 'wechat/sns/user_profile'
5
6
 
6
7
  module Wechat
7
8
  module SNS
8
- # Your code goes here...
9
9
  end
10
10
  end
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{This gem is a low level library for Wechat SNS APIs.}
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.2'
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-17 00:00:00.000000000 Z
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
- description: This gem is a low level library for Wechat SNS APIs.
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: []