Class: YxSdk::Client
Instance Attribute Summary collapse
-
#app_key ⇒ Object
Returns the value of attribute app_key.
-
#app_secret ⇒ Object
Returns the value of attribute app_secret.
Instance Method Summary collapse
- #get_header ⇒ Object
-
#http_post(url, post_body = {}, url_params = {}, endpoint = "plain") ⇒ Object
暴露出:http_get,http_post两个方法,方便第三方开发者扩展未开发的微信API。.
-
#initialize(app_key, app_secret) ⇒ Client
constructor
A new instance of Client.
Methods included from Api::User
#create, #refreshToken, #update
Constructor Details
#initialize(app_key, app_secret) ⇒ Client
Returns a new instance of Client.
10 11 12 13 |
# File 'lib/yx_sdk/client.rb', line 10 def initialize(app_key, app_secret) @app_key = app_key @app_secret = app_secret end |
Instance Attribute Details
#app_key ⇒ Object
Returns the value of attribute app_key.
8 9 10 |
# File 'lib/yx_sdk/client.rb', line 8 def app_key @app_key end |
#app_secret ⇒ Object
Returns the value of attribute app_secret.
8 9 10 |
# File 'lib/yx_sdk/client.rb', line 8 def app_secret @app_secret end |
Instance Method Details
#get_header ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/yx_sdk/client.rb', line 21 def get_header = Time.now.to_i noncestr = SecureRandom.hex(16) str = "#{AppSecret}#{noncestr}#{}" signature = Digest::SHA1.hexdigest(str) { "AppKey" => @app_key, "Nonce" => noncestr, "CurTime" => , "CheckSum" => signature, "Content-Type" => "application/x-www-form-urlencoded;charset=utf-8" } end |
#http_post(url, post_body = {}, url_params = {}, endpoint = "plain") ⇒ Object
暴露出:http_get,http_post两个方法,方便第三方开发者扩展未开发的微信API。
16 17 18 19 |
# File 'lib/yx_sdk/client.rb', line 16 def http_post(url, post_body={}, url_params={}, endpoint="plain") # url_params = url_params.merge(access_token_param) YxSdk.http_post_without_token(url, post_body, url_params, get_header, endpoint) end |