Module: Tencent::Sms
- Defined in:
- lib/tencent/sms.rb,
lib/tencent/sms/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Class Attribute Summary collapse
-
.appid ⇒ Object
Returns the value of attribute appid.
-
.appkey ⇒ Object
Returns the value of attribute appkey.
Class Method Summary collapse
- .config {|_self| ... } ⇒ Object
- .random_number ⇒ Object
- .sendsms(message) ⇒ Object
- .sig(random, time, mobile) ⇒ Object
Class Attribute Details
.appid ⇒ Object
Returns the value of attribute appid.
9 10 11 |
# File 'lib/tencent/sms.rb', line 9 def appid @appid end |
.appkey ⇒ Object
Returns the value of attribute appkey.
9 10 11 |
# File 'lib/tencent/sms.rb', line 9 def appkey @appkey end |
Class Method Details
.config {|_self| ... } ⇒ Object
11 12 13 |
# File 'lib/tencent/sms.rb', line 11 def config yield self if block_given? end |
.random_number ⇒ Object
40 41 42 |
# File 'lib/tencent/sms.rb', line 40 def random_number rand(10_000...99_999) end |
.sendsms(message) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/tencent/sms.rb', line 15 def sendsms() random = random_number time = Time.now.to_i body = { :ext => "", :extend => "", :params => [:params], :sig => sig(random, time, [:mobile]), :sign => [:sign], :tel => { :mobile => [:mobile], :nationcode => [:nationcode] }, :time => time, :tpl_id => [: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) ⇒ Object
36 37 38 |
# File 'lib/tencent/sms.rb', line 36 def sig(random, time, mobile) Digest::SHA256.hexdigest "appkey=#{appkey}&random=#{random}&time=#{time}&mobile=#{mobile}" end |