aliyun-vms 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rspec +3 -0
- data/README.md +9 -31
- data/aliyun-vms.gemspec +4 -3
- data/lib/aliyun/vms.rb +6 -6
- data/lib/aliyun/vms/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b40cce516c48b72522da6e8fc089685ed72353a8bfee01ba69179950c42fc61
|
4
|
+
data.tar.gz: 992c39df4a2303213a105523229aecb85957ada71931fa0da2cf7ba3a3967449
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9715a5a791977442f44cf66a15d8ea75042d522c584d062bb6002fee132a7fa6f07d7586173bfa3634eb733495af7708bceb66d688024ad8a08cbd3a73478b13
|
7
|
+
data.tar.gz: 00f60eeb3c215bcfbaf43d83857f681238738180586378cd89a8c0891d6e1e7d77136c87d795516da7f15cd6f88bdb5e87e22f9400a8bd1e9ef4970fda257877
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/README.md
CHANGED
@@ -73,7 +73,7 @@ require 'aliyun/vms'
|
|
73
73
|
可以改为 Github 安装源,例如 Rails Gemfile 文件引用可以改为下面格式,即可正确安装。
|
74
74
|
|
75
75
|
```ruby
|
76
|
-
gem 'aliyun-vms', '0.0.
|
76
|
+
gem 'aliyun-vms', '0.0.3', git: 'https://github.com/kejincan0527/aliyun-vms.git'
|
77
77
|
```
|
78
78
|
|
79
79
|
## Usage 使用
|
@@ -95,17 +95,16 @@ $ require 'aliyun/vms'
|
|
95
95
|
参数设置:
|
96
96
|
|
97
97
|
```ruby
|
98
|
-
|
98
|
+
> Aliyun::Vms.configure do |config|
|
99
99
|
config.access_key_secret = ACCESS_KEY_SECRET # 阿里云接入密钥,在阿里云控制台申请
|
100
100
|
config.access_key_id = ACCESS_KEY_ID # 阿里云接入 ID, 在阿里云控制台申请
|
101
|
-
config.action = 'SingleCallByTts' # 默认设置
|
102
101
|
config.format = 'XML' # 语音推送返回信息格式,可以填写 'JSON'或者'XML'
|
103
|
-
config.region_id = 'cn-hangzhou' # 默认设置,如果没有特殊需要,可以不改
|
102
|
+
config.region_id = 'cn-hangzhou' # 默认设置,如果没有特殊需要,可以不改
|
103
|
+
config.action = 'SingleCallByTts' # 默认设置
|
104
104
|
config.signature_method = 'HMAC-SHA1' # 加密算法,默认设置
|
105
105
|
config.signature_version = '1.0' # 签名版本,默认设置,不用修改
|
106
106
|
config.version = '2017-05-25' # 服务版本,默认设置,不用修改
|
107
107
|
end
|
108
|
-
|
109
108
|
```
|
110
109
|
返回
|
111
110
|
|
@@ -138,14 +137,9 @@ config/initializers/aliyun-vms.rb
|
|
138
137
|
|
139
138
|
```ruby
|
140
139
|
Aliyun::Vms.configure do |config|
|
141
|
-
config.access_key_secret = ACCESS_KEY_SECRET
|
142
|
-
config.access_key_id = ACCESS_KEY_ID
|
143
|
-
config.
|
144
|
-
config.format = 'XML' # 语音推送返回信息格式,可以填写 'JSON'或者'XML'
|
145
|
-
config.region_id = 'cn-hangzhou' # 默认设置,如果没有特殊需要,可以不改
|
146
|
-
config.signature_method = 'HMAC-SHA1' # 加密算法,默认设置
|
147
|
-
config.signature_version = '1.0' # 签名版本,默认设置,不用修改
|
148
|
-
config.version = '2017-05-25' # 服务版本,默认设置,不用修改
|
140
|
+
config.access_key_secret = ACCESS_KEY_SECRET
|
141
|
+
config.access_key_id = ACCESS_KEY_ID
|
142
|
+
config.format = 'JSON'
|
149
143
|
end
|
150
144
|
```
|
151
145
|
之后,重新启动 Rails,加载配置。
|
@@ -153,32 +147,16 @@ end
|
|
153
147
|
#### 第二步:
|
154
148
|
|
155
149
|
在 Rails 应用中调用语音发送代码:
|
156
|
-
|
157
|
-
```ruby
|
158
|
-
Aliyun::Vms.send(called_show_number, called_number, tts_code, tts_param, out_id)
|
159
|
-
```
|
160
|
-
|
161
|
-
参数说明:
|
162
|
-
|
163
|
-
1. called_show_number: 被叫显示号码,必须为字符型,例如 '057112345678';
|
164
|
-
2. called_number: 接收语音的手机号,必须为字符型,例如 '1234567890';
|
165
|
-
3. tts\_code: 语音模版代码,必须为字符型,申请开通语音服务后,由阿里云提供,例如 'TTS_12345678';
|
166
|
-
4. tts\_param: 请求字符串,向语音模版提供参数,必须是转为字符串的json格式对象,例如 '{"code":"666666", "product":"测试网站" }';
|
167
|
-
5. out_id: 外部流水扩展字段,必须为字符型,可以为空。
|
168
|
-
|
169
|
-
特别说明:
|
170
|
-
|
171
|
-
在程序中可以先用 HASH 组织 tts\_param 内容,再使用 to_json 方法转换为 json 格式字符串,例如:
|
172
|
-
|
173
150
|
```ruby
|
174
151
|
...
|
175
152
|
called_show_number = '057112345678'
|
176
153
|
called_number = '1234567890'
|
177
154
|
tts_code = 'TTS_12345678'
|
155
|
+
# 在程序中可以先用 HASH 组织 tts\_param 内容,再使用 to_json 方法转换为 json 格式字符串,例如:
|
178
156
|
tts_param = {"code"=>"666666", "product"=>"测试网站" }.to_json
|
179
157
|
Aliyun::Vms.send(called_show_number, called_number, tts_code, tts_param)
|
180
158
|
...
|
181
|
-
```
|
159
|
+
```
|
182
160
|
|
183
161
|
## Development 开发
|
184
162
|
|
data/aliyun-vms.gemspec
CHANGED
@@ -14,9 +14,10 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "https://github.com/kejincan0527/aliyun-vms"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
21
|
end
|
21
22
|
spec.bindir = "exe"
|
22
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
data/lib/aliyun/vms.rb
CHANGED
@@ -16,12 +16,12 @@ module Aliyun
|
|
16
16
|
def initialize
|
17
17
|
@access_key_secret = ''
|
18
18
|
@access_key_id = ''
|
19
|
-
@action = ''
|
20
|
-
@format = ''
|
21
|
-
@region_id = ''
|
22
|
-
@signature_method = ''
|
23
|
-
@signature_version = ''
|
24
|
-
@version = ''
|
19
|
+
@action = 'SingleCallByTts'
|
20
|
+
@format = 'XML'
|
21
|
+
@region_id = 'cn-hangzhou'
|
22
|
+
@signature_method = 'HMAC-SHA1'
|
23
|
+
@signature_version = '1.0'
|
24
|
+
@version = '2017-05-25'
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
data/lib/aliyun/vms/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aliyun-vms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wells Muker
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,6 +75,7 @@ extensions: []
|
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
77
|
- ".gitignore"
|
78
|
+
- ".rspec"
|
78
79
|
- CODE_OF_CONDUCT.md
|
79
80
|
- Gemfile
|
80
81
|
- LICENSE.txt
|