From bd12ea169de3e4fffaaaabd8c95ca67b4109e82b Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 12 Aug 2016 16:58:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/new_comment.rb | 16 ++++++++++++++++ lib/wechat/lib/wechat/api.rb | 4 +--- 2 files changed, 17 insertions(+), 3 deletions(-) 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