获取未关注修改
This commit is contained in:
parent
8ab003d5ee
commit
4eec1f5d4e
|
@ -57,23 +57,30 @@ module Mobile
|
|||
subscribe = 0 #默认未关注
|
||||
|
||||
#-------------------获取用户是否关注此公众号-----------------------------
|
||||
access_token = session[:access_token]
|
||||
refresh_token = session[:refresh_token]
|
||||
openid = session[:wechat_openid]
|
||||
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||
user_info = Wechat.api.user(openid)
|
||||
Rails.logger.info "user_info!!!!!!!!!"
|
||||
Rails.logger.info user_info
|
||||
subscribe = user_info["subscribe"]
|
||||
|
||||
if access_token.present? && refresh_token.present?
|
||||
refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
|
||||
|
||||
access_token = refreshinfo["access_token"]
|
||||
refresh_token = refreshinfo["refresh_token"]
|
||||
session[:access_token] = access_token
|
||||
session[:refresh_token] = refresh_token
|
||||
|
||||
#获取用户信息
|
||||
user_info = Wechat.api.web_user_info(access_token,openid)
|
||||
Rails.logger.info "user_info!!!!!!!!!"
|
||||
Rails.logger.info user_info
|
||||
subscribe = user_info["subscribe"]
|
||||
end
|
||||
# access_token = session[:access_token]
|
||||
# refresh_token = session[:refresh_token]
|
||||
#
|
||||
# if access_token.present? && refresh_token.present?
|
||||
# refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
|
||||
#
|
||||
# access_token = refreshinfo["access_token"]
|
||||
# refresh_token = refreshinfo["refresh_token"]
|
||||
# session[:access_token] = access_token
|
||||
# session[:refresh_token] = refresh_token
|
||||
#
|
||||
# #获取用户信息
|
||||
# user_info = Wechat.api.web_user_info(access_token,openid)
|
||||
# Rails.logger.info "user_info!!!!!!!!!"
|
||||
# Rails.logger.info user_info
|
||||
# subscribe = user_info["subscribe"]
|
||||
# end
|
||||
|
||||
status = 0
|
||||
tip = 0 #0班级1项目
|
||||
|
|
Loading…
Reference in New Issue