Commit f5edbef5 by lanrion

重构生成二维码接口

parent 9117933a
...@@ -6,31 +6,27 @@ module WeixinAuthorize ...@@ -6,31 +6,27 @@ 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"
qrcode_infos = {action_name: "QR_SCENE", expire_seconds: expire_seconds} qrcode_infos = {action_name: "QR_SCENE", expire_seconds: expire_seconds}
qrcode_infos = qrcode_infos.merge(action_info(scene_id)) qrcode_infos.merge!(action_info(scene_id))
http_post(post_url, qrcode_infos) http_post(qrcode_base_url, qrcode_infos)
end end
# 永久二维码 # 永久二维码
# options: scene_id, scene_str # options: scene_id, scene_str
def create_qr_limit_scene(options) def create_qr_limit_scene(options)
scene_id = options[:scene_id] scene_id = options[:scene_id]
scene_str = options[:scene_str]
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)) qrcode_infos.merge!(action_info(scene_id))
http_post(post_url, qrcode_infos) http_post(qrcode_base_url, qrcode_infos)
end end
# 为永久的字符串参数值 # 为永久的字符串参数值
# options: scene_str # options: scene_str
def create_qr_limit_str_scene(options) def create_qr_limit_str_scene(options)
scene_str = options[:scene_str] scene_str = options[:scene_str]
post_url = "#{qrcode_base_url}/create"
qrcode_infos = {action_name: "QR_LIMIT_STR_SCENE"} qrcode_infos = {action_name: "QR_LIMIT_STR_SCENE"}
qrcode_infos = qrcode_infos.merge(action_info(nil, scene_str)) qrcode_infos.merge!(action_info(nil, scene_str))
http_post(post_url, qrcode_infos) http_post(qrcode_base_url, qrcode_infos)
end end
...@@ -42,7 +38,7 @@ module WeixinAuthorize ...@@ -42,7 +38,7 @@ module WeixinAuthorize
private private
def qrcode_base_url def qrcode_base_url
"/qrcode" "/qrcode/create"
end end
def action_info(scene_id, scene_str=nil) def action_info(scene_id, scene_str=nil)
......
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