Class: MpWeixin::Interface::Promotion
- Defined in:
- lib/mp_weixin/interface/promotion.rb
Overview
推广支持 生成带参数的二维码
Instance Method Summary collapse
-
#create(opts = nil) ⇒ Object
创建二维码ticket:.
- #showqrcode(arg = nil) ⇒ Object
Methods inherited from Base
#default_request_params, #get, #initialize, #post, #request
Constructor Details
This class inherits a constructor from MpWeixin::Interface::Base
Instance Method Details
#create(opts = nil) ⇒ Object
创建二维码ticket:
临时二维码请求说明 http请求方式: POST URL: api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKEN POST数据格式:json POST数据例子:1800, “action_name”: “QR_SCENE”, “action_info”: {“scene”: {“scene_id”: 123}} 永久二维码请求说明 http请求方式: POST URL: api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKEN POST数据格式:json POST数据例子:“QR_LIMIT_SCENE”, “action_info”: {“scene”: {“scene_id”: 123}}
21 22 23 24 25 26 27 |
# File 'lib/mp_weixin/interface/promotion.rb', line 21 def create(opts = nil) # JSON.generate(user_message.protocol_params, :ascii_only => true) opts_json = JSON.generate(opts, :ascii_only => false) if opts.is_a?(Hash) # http://rubydoc.info/gems/faraday/0.5.3/Faraday/Request post '/cgi-bin/qrcode/create', :body => opts_json, :params => default_request_params end |
#showqrcode(arg = nil) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/mp_weixin/interface/promotion.rb', line 35 def showqrcode(arg = nil) if arg.present? opts = arg.is_a?(Hash) ? arg : {ticket: arg} get '/cgi-bin/showqrcode', :params => opts.merge(default_request_params) do |req| req.url 'https://mp.weixin.qq.com/cgi-bin/showqrcode', default_request_params req end end end |