diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index e9dc03f0e..65189daa1 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -214,7 +214,10 @@ class WechatsController < ActionController::Base private def get_openid(code) url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=#{Wechat.config.appid}&secret=#{Wechat.config.secret}&code=#{code}&grant_type=authorization_code" - JSON.parse(URI.parse(url).read)["openid"] + logger.debug url + body = URI.parse(url).read + logger.debug body + JSON.parse(body)["openid"] end diff --git a/public/javascripts/wechat/auth.js b/public/javascripts/wechat/auth.js index 79f5f96a1..44c90c836 100644 --- a/public/javascripts/wechat/auth.js +++ b/public/javascripts/wechat/auth.js @@ -15,12 +15,10 @@ $(function(){ } window.getOpenId = function(cb){ - alert(g_openid); if (g_openid.length>0){ cb(g_openid); } var code = getUrlParam("code"); - alert(code); $.ajax({ url: '/wechat/get_open_id?code='+code, type: 'get',