Class: WeixinAuthorize::Client

Inherits:
Object
  • Object
show all
Includes:
Api::Custom, Api::Groups, Api::Media, Api::Menu, Api::Qrcode, Api::User
Defined in:
lib/weixin_authorize/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Api::Media

#download_media_url, #upload_media

Methods included from Api::Qrcode

#create_qr_limit_scene, #create_qr_scene, #qr_code_url

Methods included from Api::Groups

#create_group, #get_group_for, #groups, #update_group_for_openid, #update_group_name

Methods included from Api::Custom

#send_image_custom, #send_music_custom, #send_news_custom, #send_text_custom, #send_video_custom, #send_voice_custom

Methods included from Api::Menu

#create_menu, #delete_menu, #menu

Methods included from Api::User

#followers, #user

Constructor Details

#initialize(app_id, app_secret, redis_key = nil) ⇒ Client

Returns a new instance of Client.



18
19
20
21
22
23
24
# File 'lib/weixin_authorize/client.rb', line 18

def initialize(app_id, app_secret, redis_key=nil)
  @app_id     = app_id
  @app_secret = app_secret
  @expired_at = Time.now.to_i
  @redis_key  = security_redis_key((redis_key || "weixin_" + app_id))
  @storage    = Storage.init_with(self)
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



15
16
17
# File 'lib/weixin_authorize/client.rb', line 15

def access_token
  @access_token
end

#app_idObject

Time.now + expires_in



14
15
16
# File 'lib/weixin_authorize/client.rb', line 14

def app_id
  @app_id
end

#app_secretObject

Time.now + expires_in



14
15
16
# File 'lib/weixin_authorize/client.rb', line 14

def app_secret
  @app_secret
end

#expired_atObject

Time.now + expires_in



14
15
16
# File 'lib/weixin_authorize/client.rb', line 14

def expired_at
  @expired_at
end

#redis_keyObject

Returns the value of attribute redis_key.



15
16
17
# File 'lib/weixin_authorize/client.rb', line 15

def redis_key
  @redis_key
end

#storageObject

Returns the value of attribute storage.



16
17
18
# File 'lib/weixin_authorize/client.rb', line 16

def storage
  @storage
end

Instance Method Details

#get_access_tokenObject

return token



27
28
29
# File 'lib/weixin_authorize/client.rb', line 27

def get_access_token
  @storage.access_token
end

#is_valid?Boolean

检查appid和app_secret是否有效。

Returns:

  • (Boolean)


32
33
34
# File 'lib/weixin_authorize/client.rb', line 32

def is_valid?
  @storage.valid?
end