Commit 4d7300cc by lanrion

refactor qrcode api

parent d4edd9ab
...@@ -7,23 +7,22 @@ module WeixinAuthorize ...@@ -7,23 +7,22 @@ module WeixinAuthorize
# 临时二维码 # 临时二维码
def create_qr_scene(scene_id, expire_seconds=1800) def create_qr_scene(scene_id, expire_seconds=1800)
post_url = "#{qrcode_base_url}/create" post_url = "#{qrcode_base_url}/create"
qrcode_infos = {action_name: "QR_SCENE"} qrcode_infos = {action_name: "QR_SCENE", expire_seconds: expire_seconds}
qrcode_infos = qrcode_infos.merge(action_info(scene_id, expire_seconds)) qrcode_infos = qrcode_infos.merge(action_info(scene_id))
http_post(post_url, qrcode_infos) http_post(post_url, qrcode_infos)
end end
# 临时二维码 # 临时二维码
def create_qr_limit_scene(scene_id, expire_seconds=1800) def create_qr_limit_scene(scene_id)
post_url = "#{qrcode_base_url}/create" post_url = "#{qrcode_base_url}/create"
qrcode_infos = {action_name: "QR_LIMIT_SCENE"} qrcode_infos = {action_name: "QR_LIMIT_SCENE"}
qrcode_infos = qrcode_infos.merge(action_info(scene_id, expire_seconds)) qrcode_infos = qrcode_infos.merge(action_info(scene_id))
http_post(post_url, qrcode_infos) http_post(post_url, qrcode_infos)
end end
# 通过ticket换取二维码 # 通过ticket换取二维码, 直接访问即可显示!
def get_qr_code(ticket) def qr_code_url(ticket)
get_url = "/showqrcode" "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=#{ticket}"
http_get(get_url, {ticket: ticket})
end end
private private
...@@ -32,8 +31,8 @@ module WeixinAuthorize ...@@ -32,8 +31,8 @@ module WeixinAuthorize
"/qrcode" "/qrcode"
end end
def action_info(scene_id, expire_seconds) def action_info(scene_id)
{expire_seconds: expire_seconds, action_info: {scene: {scene_id: scene_id}}} {action_info: {scene: {scene_id: scene_id}}}
end end
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