Commit 1ab28bb9 by lanrion

updated client.rb

parent b6f3cf92
......@@ -3,12 +3,12 @@
module WeixinAuthorize
class Client
attr_accessor :app_id, :app_secret, :expired_at # Time.now + expires_in
include Api::User
include Api::Menu
include Api::Custom
include Api::Groups
attr_accessor :app_id, :app_secret, :expired_at # Time.now + expires_in
attr_accessor :access_token
def initialize(app_id="", app_secret="", expired_at=nil)
......@@ -21,7 +21,7 @@ module WeixinAuthorize
# return token
def get_access_token
# 如果当前token过期时间小于现在的时间,则重新获取一次
if @expired_at < Time.now.to_i
if @expired_at <= Time.now.to_i
authenticate
end
@access_token
......@@ -44,5 +44,9 @@ module WeixinAuthorize
"https://api.weixin.qq.com/cgi-bin"
end
def access_token_param
"access_token=#{get_access_token}"
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment