diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index fd578c78d..0dacef8f5 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -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] diff --git a/lib/wechat/lib/wechat/api.rb b/lib/wechat/lib/wechat/api.rb index 6ab74acc2..db1248ab0 100644 --- a/lib/wechat/lib/wechat/api.rb +++ b/lib/wechat/lib/wechat/api.rb @@ -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