Commit cc681b1c by lanrion

refactor http post

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