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

23 lines
522 B

class Wechat::OfficialAccount
class << self
attr_accessor :appid, :secret
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 access_token
client.access_token
end
def jsapi_ticket
client.jsapi_ticket
end
def client
@_client ||= Wechat::Client.new(appid, secret)
end
end
end