module WeixinAuthorize::Api::Qrcode

def action_info(scene_id, scene_str=nil)

def action_info(scene_id, scene_str=nil)
  scene_info = {}
  scene_info[:scene_id] = scene_id if !scene_id.nil?
  scene_info[:scene_str] = scene_str if !scene_str.nil?
  {action_info: {scene: scene_info}}
end

def create_qr_limit_scene(options)

options: scene_id, scene_str
永久二维码
def create_qr_limit_scene(options)
  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 = qrcode_infos.merge(action_info(scene_id))
  http_post(post_url, qrcode_infos)
end

def create_qr_limit_str_scene(options)

options: scene_str
为永久的字符串参数值
def create_qr_limit_str_scene(options)
  scene_str = options[:scene_str]
  post_url     = "#{qrcode_base_url}/create"
  qrcode_infos = {action_name: "QR_LIMIT_STR_SCENE"}
  qrcode_infos = qrcode_infos.merge(action_info(nil, scene_str))
  http_post(post_url, qrcode_infos)
end

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 = qrcode_infos.merge(action_info(scene_id))
  http_post(post_url, qrcode_infos)
end

def qr_code_url(ticket)

通过ticket换取二维码, 直接访问即可显示!
def qr_code_url(ticket)
  WeixinAuthorize.mp_endpoint("/showqrcode?ticket=#{ticket}")
end

def qrcode_base_url

def qrcode_base_url
  "/qrcode"
end