sms_voice_flash 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f6c268dcde2706767003495096d63a729899a989
4
- data.tar.gz: b594798d9e9dc02b699b65c2464640ea60a9aab3
3
+ metadata.gz: ad33a9887f9a9e386f652c328595322a3bdfca1b
4
+ data.tar.gz: 50498cf226e02895d17d3f223bcff0e1eb4b4039
5
5
  SHA512:
6
- metadata.gz: 400834cfb92481ee0a8f2aedb653642b5cf48904c62df302710cb4bd96abf7fa94b0412bad70142574c4463e5e0bbe883a0545e0fd116daa160235b2abdcb0a6
7
- data.tar.gz: be6d1132880ef3b351b129ca45422b56dbe1b47703a4aa575dd0f36f425cb50d19cc5b2fd4e86a8fbebd870e5cfe6f39f5654e9d68fc856ac6cad3010d1fe979
6
+ metadata.gz: eb8ecae9b6ecf603e7de0e28f4e4041b6c18b4890557bf58a203745e2c45382a9c65a4addf73fd57a7cacbd9060c9dd3096e20cd83f2abab3f44fa058ebcce8d
7
+ data.tar.gz: 87cd47a4b835b765f1f70052fb5e69ed32f4fad877e7b436ae3e25e7b6dd6e23fe9b624cf6509a677aaed44e564a19ace5c6a1a8d631bb5b7d0778e9c3a61600
data/README.md CHANGED
@@ -1,28 +1,79 @@
1
1
  # SmsVoiceFlash
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sms_voice_flash`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ 一种快速接入中国移动,中国联通,中国电信的短信、语音、闪信服务平台的服务接口
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ 使开发者,能够非常方便,快捷,高效地给用户发送短信、语音、闪信通知
6
6
 
7
- ## Installation
7
+ ## 安装步骤
8
8
 
9
- Add this line to your application's Gemfile:
9
+ Gemfile文件中,添加下面这一行
10
10
 
11
11
  ```ruby
12
12
  gem 'sms_voice_flash'
13
13
  ```
14
14
 
15
- And then execute:
15
+ 然后执行
16
16
 
17
17
  $ bundle
18
18
 
19
- Or install it yourself as:
19
+ 或者手动安装
20
20
 
21
21
  $ gem install sms_voice_flash
22
22
 
23
- ## Usage
23
+ ## 参数及使用说明
24
+
25
+ ### 参数介绍
26
+ 传入参数:
27
+ - key是服务商提供给的一串字符,为不同客户的身份凭证
28
+ - sign为短信尾巴的签名,最大10个字符长度,如: "中国快递",并需要向服商提前报备
29
+ - mobile 用户手机号,支持单条发送,也支持以数组的形式发送
30
+ - content 发送内容
31
+
32
+ ### 发送短信
33
+ ```ruby
34
+ #初始化服务
35
+ #假定 key = "LKiw2STo1NvouhQ4OKOw6hrdp" sign = "中国快递"
36
+
37
+ SmsVoiceFlash.set(key,sign)
38
+
39
+ #单条发送短信
40
+ #假定mobile = "13512345678" content = "我爱Ruby"
41
+
42
+ SmsVoiceFlash.sms(mobile,content)
43
+
44
+ #多条发送
45
+ #假定 mobile = ["13512345678","13612345678","18612345678"],content="我爱ruby"
46
+
47
+ SmsVoiceFlash.sms(mobile,content)
48
+
49
+ ```
50
+ ### 返回值说明
51
+ 返回值为json格式
52
+ - code 返回码
53
+ - message 信息描述
54
+ - uid 本条消息唯一识别码,请保留用来跟跟消息的后续状态。
55
+
56
+ 返回值
57
+ - 正常返回 {"code":0,"message":"正在发送","uid":"iSrXps3QHYCt9CeoEySPrvUo6Lhr1MIg"}
58
+ - 异常返回
59
+ - {"message": "Your authentication credentials are invalid"}
60
+ - {"message":"API rate limit exceeded"} 默认发送速率为,5条每秒,如果超过上限会提示这个错误
61
+ - {"code":2,"message":"手机号码不正确","uid":""}
62
+ - {"code":3,"message":"ts参数错误,注意是秒单位,误差不能超过5分钟","uid":""}
63
+ - {"code":4,"message":"发送内容不正确","uid":""}
64
+ - {"code":5,"message":"签名信息不正确","uid":""}
65
+
66
+ ### 获取返回值
67
+
68
+ ```ruby
69
+ result = SmsVoiceFlash.sms(mobile,content)
70
+
71
+ code = result.code
72
+ message = result.code
73
+ uid = result.code
74
+
75
+ ```
24
76
 
25
- TODO: Write usage instructions here
26
77
 
27
78
  ## Development
28
79
 
@@ -32,8 +83,11 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
83
 
33
84
  ## Contributing
34
85
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sms_voice_flash. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
-
86
+ ```ruby
87
+ git clone git@github.com:luolinae86/sms_voice_flash.git
88
+ cd sms_voice_flash
89
+ bundle console # 请不要使用 irb,可能会有依赖问题
90
+ ```
37
91
 
38
92
  ## License
39
93
 
@@ -1,3 +1,3 @@
1
1
  module SmsVoiceFlash
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -14,8 +14,12 @@ module SmsVoiceFlash
14
14
  end
15
15
 
16
16
  def sms(mobile,content)
17
+ #如果用户输入的为数组,则将数组内的元素用逗号分隔成字符串
18
+ if mobile.kind_of?(Array)
19
+ mobile = mobile.map{|number| number.strip}.join(",")
20
+ end
17
21
  url = URI.encode("#{SmsUrl}?apikey=#{@key}&mobile=#{mobile}&content=#{content}&ts=#{Time.now.to_i}&sign=#{@sign}")
18
- result = JSON.parse(RestClient.get(url).body,symbolize_names: true)
22
+ result = JSON.parse(RestClient.get(url).body,object_class: OpenStruct)
19
23
  end
20
24
 
21
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sms_voice_flash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - luolin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-28 00:00:00.000000000 Z
11
+ date: 2018-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler