Class: Wechat::PlatformsController
- Inherits:
-
BaseController
- Object
- BaseController
- BaseController
- Wechat::PlatformsController
- Defined in:
- app/controllers/wechat/platforms_controller.rb
Instance Method Summary collapse
- #callback ⇒ Object
-
#message ⇒ Object
消息与事件接收URL: platforms/:id/callback/$APPID$.
-
#notify ⇒ Object
授权事件接收URL: platforms/notice.
- #show ⇒ Object
Instance Method Details
#callback ⇒ Object
23 24 25 26 27 28 |
# File 'app/controllers/wechat/platforms_controller.rb', line 23 def callback @auth = @platform.auths.build @auth.auth_code = params[:auth_code] @auth.auth_code_expires_at = Time.current + params[:expires_in].to_i @auth.save end |
#message ⇒ Object
消息与事件接收URL: platforms/:id/callback/$APPID$
31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/wechat/platforms_controller.rb', line 31 def @receive = @platform.receives.build @receive.appid = params[:appid] r = Hash.from_xml(request.body.read)['xml'] @receive.encrypt_data = r['Encrypt'] @receive.save render plain: @receive.request.to_wechat end |
#notify ⇒ Object
授权事件接收URL: platforms/notice
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/wechat/platforms_controller.rb', line 7 def notify @ticket = Ticket.new(ticket_params) r = Hash.from_xml(request.raw_post)['xml'] @ticket.appid = r['AppId'] @ticket.ticket_data = r['Encrypt'] if @ticket.save render plain: 'success' else head :no_content end end |
#show ⇒ Object
20 21 |
# File 'app/controllers/wechat/platforms_controller.rb', line 20 def show end |