This commit is contained in:
yuanke 2016-08-12 16:58:48 +08:00
parent be0dd6c110
commit bd12ea169d
2 changed files with 17 additions and 3 deletions

View File

@ -15,6 +15,22 @@ module Mobile
end
post ':id' do
# authenticate!
# userinfo = Wechat.api.web_userinfo("BjSzmH9GDgTwIjpv5wgWm2UQlOuaOMrTDS_rbmNaYtPT0FJrm3cNcG5y8_NT8J7i5JI6z40RBZ3p0tCf2OhFpy72-W5VuSA61NPxOTgw4JY","oCnvgv0Bf_6a_wFV3O6XyqXt-sgg")
require "open-uri"
#如果有GET请求参数直接写在URI地址中
uri = 'https://api.weixin.qq.com/sns/userinfo?access_token=BjSzmH9GDgTwIjpv5wgWm2UQlOuaOMrTDS_rbmNaYtPT0FJrm3cNcG5y8_NT8J7i5JI6z40RBZ3p0tCf2OhFpy72-W5VuSA61NPxOTgw4JY&openid=oCnvgv0Bf_6a_wFV3O6XyqXt-sgg&lang=zh_CN'
html_response = nil
open(uri) do |http|
html_response = http.read
end
html_response
Rails.logger.info "html_response!!!!!!!!!"
Rails.logger.info html_response
unless current_user
#如果当前用户不存在
openid = session[:wechat_openid]

View File

@ -130,9 +130,7 @@ module Wechat
}
# get 'https://api.weixin.qq.com/sns/userinfo',params: params
# get 'userinfo', params: params, base: OAUTH2_USERINFO
@client.get 'https://api.weixin.qq.com/sns/userinfo',params
get 'userinfo', params: params, base: OAUTH2_USERINFO
end
end
end