module Tencent::Sms
Constants
- VERSION
Attributes
appid[RW]
appkey[RW]
Public Class Methods
config() { |self| ... }
click to toggle source
# File lib/tencent/sms.rb, line 11 def config yield self if block_given? end
random_number()
click to toggle source
# File lib/tencent/sms.rb, line 40 def random_number rand(10_000...99_999) end
sendsms(message)
click to toggle source
# File lib/tencent/sms.rb, line 15 def sendsms(message) random = random_number time = Time.now.to_i body = { :ext => "", :extend => "", :params => message[:params], :sig => sig(random, time, message[:mobile]), :sign => message[:sign], :tel => { :mobile => message[:mobile], :nationcode => message[:nationcode] }, :time => time, :tpl_id => message[:tpl_id] } url = "https://yun.tim.qq.com/v5/tlssmssvr/sendsms?sdkappid=#{appid}&random=#{random}" RestClient.post(url, body.to_json) end
sig(random, time, mobile)
click to toggle source
# File lib/tencent/sms.rb, line 36 def sig(random, time, mobile) Digest::SHA256.hexdigest "appkey=#{appkey}&random=#{random}&time=#{time}&mobile=#{mobile}" end