Commit cc681b1c by lanrion

refactor http post

parent b4228a30
...@@ -98,10 +98,11 @@ module WeixinAuthorize ...@@ -98,10 +98,11 @@ module WeixinAuthorize
end end
# Refactor # Refactor
def http_post(url, options={}, endpoint="plain") def http_post(url, payload={}, headers={}, endpoint="plain")
post_api_url = endpoint_url(endpoint) + url + "?access_token=#{get_access_token}" post_api_url = endpoint_url(endpoint) + url
options = MultiJson.dump(options) # to json payload = MultiJson.dump(payload) if endpoint == "plain" # to json
JSON.parse(RestClient.post(post_api_url, options)) post_params = {:params => access_token_param.merge(headers)}
JSON.parse(RestClient.post(post_api_url, payload, post_params))
end end
def endpoint_url(endpoint) def endpoint_url(endpoint)
......
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