blsm-mp-wx 0.3.4 → 0.3.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc2f011245c2e6fd4f6467197f3a524c796e8f80
4
- data.tar.gz: 4357f0f930a6f09f26b5f33a9079261216d36244
3
+ metadata.gz: 8dd83e50e4ad1c6578569af7ceff7fb6012224ec
4
+ data.tar.gz: 0bf1585f16b7e9c9067b18c71266f4c8d8b67b5d
5
5
  SHA512:
6
- metadata.gz: 930900ba844e99cdf19d2449089c6d44d6bd9d3569c29170656d83b93f092ac53ccd0c1ef03b2b5fda2cbc57520d869077a02a528b3bbbaa388b7ca2eda0af91
7
- data.tar.gz: 5699f5cef098b018924e96a01632b272df72429bd0b3325a76bd63f35306ebcf6533c4b402059319f01f984ea49e26985d1209da7281a80064eb44dbd7484a25
6
+ metadata.gz: dd897f7ebd66a70863fc180c25cec67269b3477672c9ab65bce7766e6279f24865968a9832dfde79ed2232aa83603a97cd6039a747e2b356bb404fe1bd451f88
7
+ data.tar.gz: c3dfbfde05338e7c734e4f0bac1c2ff5e48e8bbf01d0d81da38244a4e8ed7b22d7b354db525b594e7167a4d3670e90525f76a0301285dc456a41ac56860562b1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blsm-mp-wx (0.3.4)
4
+ blsm-mp-wx (0.3.5)
5
5
 
6
6
  GEM
7
7
  remote: https://ruby.taobao.org/
@@ -1,3 +1,3 @@
1
1
  module BlsmMpWx
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
data/lib/blsm-mp-wx.rb CHANGED
@@ -405,6 +405,33 @@ module BlsmMpWx
405
405
  end
406
406
  end
407
407
 
408
+ #sns登录(公众号)获取用户信息
409
+ def sns_mp_login_userinfo(app_id, code)
410
+ conn = Faraday.new(:url => 'https://api.weixin.qq.com')
411
+ response = conn.get do |req|
412
+ req.url '/sns/oauth2/access_token'
413
+ req.params[:appid] = app_id
414
+ req.params[:secret] = VdMpWx.where(app_id: app_id).take.app_secret
415
+ req.params[:code] = code
416
+ req.params[:grant_type] = 'authorization_code'
417
+ end
418
+ response_body = response.body
419
+ res = parse_json(response_body)
420
+ return res unless res['nickname']
421
+
422
+ VdWxUser.find_or_create_by({app_id: app_id, openid: res['openid']}) do |u|
423
+ u.update_attributes({nickname: res['nickname'],
424
+ sex: res['sex'],
425
+ unionid: res['unionid'],
426
+ language: res['language'],
427
+ city: res['city'],
428
+ province: res['province'],
429
+ country: res['country'],
430
+ headimgurl: res['headimgurl'],
431
+ })
432
+ end
433
+ end
434
+
408
435
  private
409
436
  #解析json类型的数据,并将最后的数据转为hash或array
410
437
  # +json_data_str+ 要转换的json数据
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blsm-mp-wx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - saxer