Commit 44882ef5 by lanrion

added file_endpoint for upload

parent 5bd539ea
...@@ -39,16 +39,20 @@ module WeixinAuthorize ...@@ -39,16 +39,20 @@ module WeixinAuthorize
{grant_type: "client_credential", appid: app_id, secret: app_secret} {grant_type: "client_credential", appid: app_id, secret: app_secret}
end end
def endpoint def plain_endpoint
"https://api.weixin.qq.com/cgi-bin" "https://api.weixin.qq.com/cgi-bin"
end end
def file_endpoint
"http://file.api.weixin.qq.com/cgi-bin"
end
def access_token_param def access_token_param
{access_token: get_access_token} {access_token: get_access_token}
end end
def http_get_without_token(url, options={}) def http_get_without_token(url, options={}, endpoint="plain")
get_api_url = endpoint + url get_api_url = send("#{endpoint}_endpoint") + url
JSON.parse(RestClient.get(get_api_url, :params => options)) JSON.parse(RestClient.get(get_api_url, :params => options))
end end
...@@ -58,8 +62,8 @@ module WeixinAuthorize ...@@ -58,8 +62,8 @@ module WeixinAuthorize
end end
# Refactor # Refactor
def http_post(url, options={}) def http_post(url, options={}, endpoint="plain")
post_api_url = endpoint + url + "?access_token=#{get_access_token}" post_api_url = send("#{endpoint}_endpoint") + url + "?access_token=#{get_access_token}"
JSON.parse(RestClient.post(post_api_url ,options)) JSON.parse(RestClient.post(post_api_url ,options))
end end
......
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