Sha256: b89ac053dfb7b8a82e53d714f1e2ab5d42bac019789f90603e457b92158a143d

Contents?: true

Size: 766 Bytes

Versions: 4

Compression:

Stored size: 766 Bytes

Contents

##
# Ticket 类提供根据访问令牌 access_token 获取 JSAPI Ticket 的方法。如:
# jsapi_ticket = Wechat::JSAPI::Ticket.create access_token

class Wechat::JSAPI::Ticket

  extend Wechat::Core::Common

  ##
  # 获得jsapi_ticket
  # http://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html#.E9.99.84.E5.BD.951-JS-SDK.E4.BD.BF.E7.94.A8.E6.9D.83.E9.99.90.E7.AD.BE.E5.90.8D.E7.AE.97.E6.B3.95
  #
  # Return hash format if success:
  # {
  #   errcode:    0,
  #   errmsg:     'ok',
  #   ticket:     <JSAPI_TICKET>,
  #   expires_in: 7200
  # }
  def self.create(access_token)

    assert_present! :access_token, access_token

    get_json "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=#{access_token}&type=jsapi"

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wechat-jsapi-1.1 lib/wechat/jsapi/ticket.rb
wechat-jsapi-1.0 lib/wechat/jsapi/ticket.rb
wechat-jsapi-0.1.3 lib/wechat/jsapi/ticket.rb
wechat-jsapi-0.1.2 lib/wechat/jsapi/ticket.rb