Commit 597308a8 by lanrion

refactor

parent 9432c4cb
...@@ -11,18 +11,18 @@ module WeixinAuthorize ...@@ -11,18 +11,18 @@ module WeixinAuthorize
def http_get_without_token(url, headers={}, endpoint="plain") def http_get_without_token(url, headers={}, endpoint="plain")
get_api_url = endpoint_url(endpoint, url) get_api_url = endpoint_url(endpoint, url)
json_parse(RestClient.get(get_api_url, :params => headers)) load_json(RestClient.get(get_api_url, :params => headers))
end end
def http_post_without_token(url, payload={}, headers={}, endpoint="plain") def http_post_without_token(url, payload={}, headers={}, endpoint="plain")
post_api_url = endpoint_url(endpoint, url) post_api_url = endpoint_url(endpoint, url)
payload = MultiJson.dump(payload) if endpoint == "plain" # to json payload = MultiJson.dump(payload) if endpoint == "plain" # to json
json_parse(RestClient.post(post_api_url, payload, headers)) load_json(RestClient.post(post_api_url, payload, headers))
end end
# return hash # return hash
def json_parse(json) def load_json(string)
JSON.parse(json) JSON.parse(string)
end end
def endpoint_url(endpoint, url) def endpoint_url(endpoint, url)
......
# encoding: utf-8 # encoding: utf-8
require "redis" require "redis"
require 'digest' require 'digest/md5'
module WeixinAuthorize module WeixinAuthorize
class Client class Client
......
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