Class: SimpleWx::AccessToken
- Inherits:
-
Base
- Object
- Base
- SimpleWx::AccessToken
show all
- Defined in:
- lib/simple_wx/access_token.rb
Instance Attribute Summary
Attributes inherited from Base
#error, #raise_flag
Instance Method Summary
collapse
Methods inherited from Base
#initialize, method_missing
Constructor Details
This class inherits a constructor from SimpleWx::Base
Instance Method Details
#access_token ⇒ Object
30
31
32
33
|
# File 'lib/simple_wx/access_token.rb', line 30
def access_token
SimpleWx.redis.exists("__weixin_access_token__") ? \
SimpleWx.redis.get("__weixin_access_token__") : get_new_token
end
|
#jsapi_ticket ⇒ Object
35
36
37
38
|
# File 'lib/simple_wx/access_token.rb', line 35
def jsapi_ticket
SimpleWx.redis.exists("__jsapi_ticket__") ? \
SimpleWx.redis.get("__jsapi_ticket__") : get_new_jsapi_ticket
end
|
#server_ip ⇒ Object
23
24
25
26
27
28
|
# File 'lib/simple_wx/access_token.rb', line 23
def server_ip
url = "https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=#{access_token}"
response = RestClient.get url
response_json = errcode_check(JSON.parse(response))
@server_ip = response_json["ip_list"]
end
|