You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/libs/wechat/official_account.rb

17 lines
466 B

class Wechat::OfficialAccount
class << self
attr_accessor :appid, :secret
delegate :access_token, :jsapi_ticket, to: :client
def js_sdk_signature(url, noncestr, timestamp)
data = { jsapi_ticket: jsapi_ticket, noncestr: noncestr, timestamp: timestamp, url: url }
str = data.map { |k, v| "#{k}=#{v}" }.join('&')
Digest::SHA1.hexdigest(str)
end
def client
@_client ||= Wechat::Client.new(appid, secret)
end
end
end