|
|
@ -442,18 +442,6 @@ class WechatsController < ActionController::Base
|
|
|
|
def get_openid_from_code(code)
|
|
|
|
def get_openid_from_code(code)
|
|
|
|
return 'oCnvgvz8R7QheXE-R9Kkr39j8Ndg' if code =='only-for-test'
|
|
|
|
return 'oCnvgvz8R7QheXE-R9Kkr39j8Ndg' if code =='only-for-test'
|
|
|
|
openid = session[:wechat_openid]
|
|
|
|
openid = session[:wechat_openid]
|
|
|
|
|
|
|
|
|
|
|
|
info = wechat.web_access_token(code)
|
|
|
|
|
|
|
|
openid =info["openid"]
|
|
|
|
|
|
|
|
access_token =info["access_token"]
|
|
|
|
|
|
|
|
if access_token
|
|
|
|
|
|
|
|
session[:access_token] = access_token
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
refresh_token = info["refresh_token"]
|
|
|
|
|
|
|
|
if refresh_token
|
|
|
|
|
|
|
|
session[:refresh_token] = refresh_token
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unless openid
|
|
|
|
unless openid
|
|
|
|
if code
|
|
|
|
if code
|
|
|
|
#不能联系调两次web_access_token 否则会提示请在微信客户端打开次链接
|
|
|
|
#不能联系调两次web_access_token 否则会提示请在微信客户端打开次链接
|
|
|
|