diff --git a/lib/dingtalk/api/base.rb b/lib/dingtalk/api/base.rb index 9b3502e..6778e39 100644 --- a/lib/dingtalk/api/base.rb +++ b/lib/dingtalk/api/base.rb @@ -43,12 +43,14 @@ module Dingtalk end def http_get(url, params = {}) - res = RestClient.get(*payload(url, params)) + p = default_params.merge(params) + res = RestClient.get(request_url(url), p.to_json, content_type: :json) JSON.parse(res) end def http_post(url, params = {}) - res = RestClient.post(*payload(url, params)) + p = default_params.merge(params) + res = RestClient.post(request_url(url), p.to_json, content_type: :json) JSON.parse(res) end diff --git a/lib/dingtalk/api/suite.rb b/lib/dingtalk/api/suite.rb index 2338f98..e8cb70d 100644 --- a/lib/dingtalk/api/suite.rb +++ b/lib/dingtalk/api/suite.rb @@ -12,10 +12,9 @@ module Dingtalk def get_permanent_code(tmp_auth_code) params = { - suite_access_token: suite_access_token, tmp_auth_code: tmp_auth_code } - http_post('get_permanent_code', params) + http_post("get_permanent_code?suite_access_token=#{suite_access_token}", params) end def suite_access_token diff --git a/lib/dingtalk/client.rb b/lib/dingtalk/client.rb index 133a6d0..9541503 100644 --- a/lib/dingtalk/client.rb +++ b/lib/dingtalk/client.rb @@ -11,9 +11,10 @@ module Dingtalk def response_json(return_str) the_timestamp = timestamp the_nonce = nonce + encrypted = encrypt(return_str) { - msg_signature: signature(return_str, the_timestamp, the_nonce), - encrypt: encrypt(return_str), + msg_signature: signature(return_str, encrypted, the_timestamp, the_nonce), + encrypt: encrypted, timeStamp: the_timestamp, nonce: the_nonce } @@ -23,8 +24,8 @@ module Dingtalk encrypt = Dingtalk::Prpcrypt.encrypt(aes_key, return_str, Dingtalk.suite_key) end - def signature(return_str, timestamp, nonce) - sort_params = [Dingtalk.suite_token, timestamp, nonce, encrypt(return_str)].sort.join + def signature(return_str, encrypted, the_timestamp, the_nonce) + sort_params = [Dingtalk.suite_token, the_timestamp, the_nonce, encrypted].sort.join Digest::SHA1.hexdigest(sort_params) end -- libgit2 0.21.0