Class: Wechat::Qrcode

Inherits:
DataObject show all
Defined in:
lib/wechat/data_objects/qrcode.rb

Class Method Summary collapse

Methods inherited from DataObject

get, parameterize_params, post, #request

Class Method Details

.createObject



17
18
19
20
21
# File 'lib/wechat/data_objects/qrcode.rb', line 17

def create
  options = {expire_seconds: 1800,action_name: 'QR_SCENE',
    action_info: {scene: {scene_id: 2.times.map{ 10 + Random.rand(20) }.join }}}
  post("qrcode/create", JSON.generate(options))
end

.show(ticket) ⇒ String

Returns QR code image url.

Examples:

Wechat::Qrcode.show('gQEc8DoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL0xFUG15QWJtMHBhci1FMV9uMjJCAAIEL3gHVAMECAcAAA==')

Parameters:

  • ticket (String)

    the ticket number of qr code obtained from create

Returns:

  • (String)

    QR code image url



32
33
34
# File 'lib/wechat/data_objects/qrcode.rb', line 32

def show(ticket) 
  return "https://mp.weixin.qq.com/cgi-bin/showqrcode/cgi-bin/showqrcode?ticket=#{CGI.escape(ticket)}"
end