Commit 29f216fc by lanrion

refactor user.rb with "http_get" and "http_post" method

parent 45a505f9
......@@ -7,21 +7,21 @@ module WeixinAuthorize
# https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
# lang: zh_CN, zh_TW, en
def user(openid, lang="zh_CN")
user_info_url = "#{user_base_url}/info?#{access_token_param}&openid=#{openid}&lang=#{lang}"
JSON.parse(RestClient.get(user_info_url))
user_info_url = "#{user_base_url}/info"
http_get(user_info_url, {openid: openid, lang: lang})
end
# https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&next_openid=NEXT_OPENID
# 获取关注者列表
def followers(next_openid=nil)
users_url = "#{user_base_url}/get?#{access_token_param}&next_openid#{next_openid}"
JSON.parse(RestClient.get(users_url))
followers_url = "#{user_base_url}/get"
http_get(followers_url, {next_openid: next_openid})
end
private
def user_base_url
"#{endpoint}/user"
"/user"
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