Merge branch 'weixin_guange' of https://git.trustie.net/jacknudt/trustieforge into weixin_guange

This commit is contained in:
Tim 2016-08-12 15:35:03 +08:00
commit b50d687224
2 changed files with 5 additions and 4 deletions

View File

@ -33,7 +33,8 @@ module Mobile
if access_token
userinfo = Wechat.api.web_userinfo(access_token,openid)
name = userinfo[:nickname]
Rails.logger.info userinfo
name = userinfo["nickname"]
else
name = openid[0..3]+"***"+openid.last
end

View File

@ -7,6 +7,7 @@ module Wechat
class Api < ApiBase
API_BASE = 'https://api.weixin.qq.com/cgi-bin/'
OAUTH2_BASE = 'https://api.weixin.qq.com/sns/oauth2/'
OAUTH2_USERINFO = 'https://api.weixin.qq.com/sns/'
def initialize(appid, secret, token_file, timeout, skip_verify_ssl, jsapi_ticket_file)
@client = Client.new(API_BASE, timeout, skip_verify_ssl)
@ -124,10 +125,9 @@ module Wechat
def web_userinfo(access_token,openid)
params = {
access_token: access_token,
openid: openid,
lang: "zh_CN"
openid: openid
}
get 'userinfo', params: params, base: OAUTH2_BASE
get 'userinfo', params: params, base: OAUTH2_USERINFO
end
end
end