blsm-mp-wx 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/blsm-mp-wx.rb +2 -29
- data/lib/blsm-mp-wx/version.rb +1 -1
- 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: b0c31e852df17e7113cdd23720706edf6546a47b
|
4
|
+
data.tar.gz: f5ffafeb397e6a3b410094cbb24308e3c028f243
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21d2fb4b82a8f25dea592848f4a5c9833b5ad4b4a454f73261ca83b48fa8f5e763da88a9d8bd8f071113a959b65afac9065fb2df5cbf3cbb0a053301a62833fb
|
7
|
+
data.tar.gz: 259b4021077f587fb1af11d23231afb75d5c4669fdfe3b225a9e49b4e6c5cf37b8bce049d40829c9daf4673ea71d9a15c915c92859c681e900a396de0ec0db96
|
data/Gemfile.lock
CHANGED
data/lib/blsm-mp-wx.rb
CHANGED
@@ -352,8 +352,8 @@ module BlsmMpWx
|
|
352
352
|
end
|
353
353
|
|
354
354
|
#sns登录获取用户信息
|
355
|
-
def sns_login_userinfo(code)
|
356
|
-
app_id = 'wx143306afc47c63a6'
|
355
|
+
def sns_login_userinfo(code,app_id=nil)
|
356
|
+
app_id = app_id || 'wx143306afc47c63a6'
|
357
357
|
app = VdMpWx.where(app_id: app_id).first
|
358
358
|
|
359
359
|
conn = Faraday.new(:url => 'https://api.weixin.qq.com')
|
@@ -405,33 +405,6 @@ 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
|
-
|
435
408
|
private
|
436
409
|
#解析json类型的数据,并将最后的数据转为hash或array
|
437
410
|
# +json_data_str+ 要转换的json数据
|
data/lib/blsm-mp-wx/version.rb
CHANGED