module WxExt::Api::Qrcode

User api of weixin.

@author FuShengYang

Public Instance Methods

create_ticket(access_token, ticket_hash) click to toggle source

Create ticket via post.

@param [Enumerable<String>] access_token @param [Hash] ticket_hash @return [Hash] Json based hash.

# File lib/wx_ext/api/msg.rb, line 19
def create_ticket(access_token, ticket_hash)
  url = 'https://api.weixin.qq.com/cgi-bin/qrcode/create'\
        "?access_token=#{access_token}"
  Helper.http_post(url, ticket_hash.to_json)
end
get_qrcode_by_ticket(ticket) click to toggle source

Get the qrcode via ticket.

@param [Enumerable<String>] ticket @return [Hash] Json based hash.

# File lib/wx_ext/api/msg.rb, line 29
def get_qrcode_by_ticket(ticket)
  url = 'https://mp.weixin.qq.com/cgi-bin/showqrcode'\
        "?ticket=#{ticket}"
  Helper.http_get url
end
long_url_2_short(access_token, action='long2short', long_url) click to toggle source

Long url to short url via post.

@param [Enumerable<String>] access_token @param [Enumerable<String>] action @param [Enumerable<String>] long_url @return [Hash] Json based hash.

# File lib/wx_ext/api/msg.rb, line 41
def long_url_2_short(access_token, action='long2short', long_url)
  url = 'https://api.weixin.qq.com/cgi-bin/shorturl'\
        "?access_token=#{access_token}"
  Helper.http_post(url, { action: action, long_url: long_url }.to_json)
end