qcloud-sms 0.0.1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/qcloud/sms.rb +26 -19
- data/lib/qcloud/sms/version.rb +1 -1
- data/qcloud-sms.gemspec +0 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dde5ab811276e2d579ee24f10021a547103962d90058bfd0cf46c5d66e00ec45
|
4
|
+
data.tar.gz: 45ba212e83bfa4074028bec9344f54590b5f66f82daa90adcee61806c272afec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 955f35dd2448f0e953fe6ebc6d2d3e9e1736ad3073a86586b6688edebf25434babfc214aebaf8e485c3037b050b6d3cc1ace3b91d60f5b01ec2e58b44c82bf40
|
7
|
+
data.tar.gz: 7fd900fae64574fe7b94114f90c2ab31fa7ae47bd68fca8b1952b646ed89bc94c0988796158307cb276ca6ae0e6152645ee35f6983d43774ff5a4695b7a42003
|
data/lib/qcloud/sms.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require "qcloud/sms/version"
|
2
|
+
require 'securerandom'
|
2
3
|
require 'digest'
|
3
|
-
require 'typhoeus
|
4
|
+
require 'typhoeus'
|
5
|
+
require 'json'
|
4
6
|
|
5
7
|
module Qcloud
|
6
8
|
module Sms
|
@@ -24,40 +26,45 @@ module Qcloud
|
|
24
26
|
yield(configuration)
|
25
27
|
end
|
26
28
|
|
27
|
-
def
|
29
|
+
def create_params(mobile, templId, params, random_number)
|
30
|
+
sms_params = {
|
31
|
+
"ext" => "",
|
32
|
+
"extend" => "",
|
33
|
+
"params" => params,
|
34
|
+
"sig" => sig(mobile, random_number),
|
35
|
+
"sign" => configuration.sign,
|
36
|
+
"tel" => {
|
37
|
+
"mobile" => mobile,
|
38
|
+
"nationcode" => "86"
|
39
|
+
},
|
40
|
+
"time" => timestamp,
|
41
|
+
"tpl_id" => templId
|
42
|
+
}
|
43
|
+
sms_params.to_json
|
44
|
+
end
|
45
|
+
|
46
|
+
def single_sender(mobile, templId, params)
|
28
47
|
random_number = random
|
29
48
|
Typhoeus.post("https://yun.tim.qq.com/v5/tlssmssvr/sendsms?sdkappid=" + configuration.app_id + "&random=" + random_number,
|
30
|
-
headers: {"Content-Type"
|
31
|
-
body:
|
32
|
-
params: params,
|
33
|
-
sig: sig(mobile, random_number),
|
34
|
-
sign: configuration.sign,
|
35
|
-
tel: {
|
36
|
-
mobile: mobile,
|
37
|
-
nationcode: "86"
|
38
|
-
},
|
39
|
-
time: timestamp,
|
40
|
-
tpl_id: templId,
|
41
|
-
extend: "",
|
42
|
-
ext: ""
|
43
|
-
}
|
49
|
+
headers: { "Content-Type": "application/json" },
|
50
|
+
body: create_params(mobile, templId, params, random_number)
|
44
51
|
)
|
45
52
|
end
|
46
53
|
|
47
54
|
# 生成数字签名
|
48
55
|
def sig(mobile, random_number)
|
49
|
-
signature = "appkey=" + configuration.app_key + "&random=" + random_number + "&time=" + timestamp + "&mobile=" + mobile
|
56
|
+
signature = "appkey=" + configuration.app_key + "&random=" + random_number + "&time=" + timestamp.to_s + "&mobile=" + mobile
|
50
57
|
Digest::SHA256.hexdigest signature
|
51
58
|
end
|
52
59
|
|
53
60
|
# 生成随机数
|
54
61
|
def random
|
55
|
-
SecureRandom.random_number.to_s.slice(-
|
62
|
+
SecureRandom.random_number.to_s.slice(-10..-1)
|
56
63
|
end
|
57
64
|
|
58
65
|
# 生成短信时间戳
|
59
66
|
def timestamp
|
60
|
-
Time.now.to_i
|
67
|
+
Time.now.to_i
|
61
68
|
end
|
62
69
|
|
63
70
|
end
|
data/lib/qcloud/sms/version.rb
CHANGED
data/qcloud-sms.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qcloud-sms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OHIMY中国
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: faraday
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
description: A Ruby Gem for using qcloud sms service.
|
84
70
|
email:
|
85
71
|
- im@ohimy.com
|