china_sms 0.0.3 → 0.0.4

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: 5451fdea00e162bca4570ec3e03d6e8c1a7d9585
4
- data.tar.gz: 982919da3acb9039d0f674e41f47778fa1da9c9c
3
+ metadata.gz: 0682a63cc1c257496c8e30315a28f8b563926fce
4
+ data.tar.gz: 4304a39419ef792e4aab1027a1ab4bd9ecce173e
5
5
  SHA512:
6
- metadata.gz: 119821e27f6959a1b17a48eacecce1fa00f17d9180bfe0118944c5d150935fcc461669d66fa44e130dfc0a9a0f8249cebb89240ff93e6227dc7a146e29cd0134
7
- data.tar.gz: 6c91a813cf3f8b38e68b2a285273a1f8df88acb714741c7bcafb5a7d9605adb7debf27f013ce3faa9c9becff4ee21448d194416e11a2343153fc52e66e2faeb0
6
+ metadata.gz: 7c3af2e58182cdf2d478d5e123a7a783075e4bb7aaee4e1e0f43ef3996fbb2cc3c06dbab30fa849cb332c8a5b930d3fa463697e013bf26872a0bec66c4a0d02b
7
+ data.tar.gz: c87be6268b368e0934fad98d9b0a989af38323610446daccfadaa2bb08f78918e3fa792be2eae3f59c3665b89d7dd4d77575e89ec1010b03386a3a21339774a7
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  所有短信平台都禁止发送私人短信,并要求在短信内容末尾加上签名后缀,如【19屋】
8
8
 
9
- * [推立方](http://tui3.com/) 专注于注册校验码等实时应用,需要[配置内容格式和签名](http://www.tui3.com/Members/smsconfigv2/),会自动在短信加上签名后缀
9
+ * [推立方](http://tui3.com/) 专注于注册校验码等实时应用,需要[配置内容格式和签名](http://www.tui3.com/Members/smsconfigv2/),会自动在短信加上签名后缀。短信计数:移动/联通每条短信的最大长度为64字符,电信每条最大长度60字符(半角、全角各算一个)。超过该长度后,短信后面自动增加分页信息(x/y),此时,每条短信最大长度需要再减3(不超过10页)
10
10
  * [短信宝](http://www.smsbao.com/)
11
11
  * [畅友网络](http://www.chanyoo.cn/) 群发短信需要半小时左右的时间审核,星期五等繁忙时段会有几个小时的延时,不适合发送注册校验码等实时短信,单次最多发送500个号码
12
12
 
@@ -33,3 +33,10 @@
33
33
  ChinaSMS.use :tui3, username: 'YOUR_USERNAME', password: 'YOUR_PASSWORD'
34
34
  ChinaSMS.to '13912345678', '[Test]China SMS gem has been released.'
35
35
  ```
36
+
37
+ ## 安全性
38
+
39
+ 在安全性方面,很多接口都是使用用户登录明文密码,推立方 和 短信宝 要好一些。
40
+
41
+ * **推立方**,不使用登录密码,而是由系统自动生成一长串 API_KEY,专用于接口调用
42
+ * **短信宝**,使用登录密码,但在调用时要先转成 MD5
@@ -9,7 +9,9 @@ module ChinaSMS
9
9
  def to(phone, content, options)
10
10
  phones = Array(phone).join(',')
11
11
  res = Net::HTTP.post_form(URI.parse(URL), k: options[:password], t: phones, c: content, p: 1, r: 'json')
12
- result JSON[res.body]
12
+ body = res.body
13
+ body = "{\"err_code\": 2, \"err_msg\":\"非法apikey:#{options[:password]}\"}" if body == 'invalid parameters'
14
+ result JSON[body]
13
15
  end
14
16
 
15
17
  def result(body)
@@ -1,3 +1,3 @@
1
1
  module ChinaSMS
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -3,11 +3,10 @@ require 'spec_helper'
3
3
 
4
4
  describe "Tui3" do
5
5
  describe "#to" do
6
- let(:username) { 'saberma' }
7
- let(:password) { '666666' }
6
+ let(:password) { '50e7a3smdl521942ea38dnf4b58c5e6b' }
8
7
  let(:url) { "http://tui3.com/api/send/" }
9
8
  let(:content) { '推立方测试:深圳 Rubyist 活动时间变更到明天下午 7:00,请留意。' }
10
- subject { ChinaSMS::Service::Tui3.to phone, content, username: username, password: password }
9
+ subject { ChinaSMS::Service::Tui3.to phone, content, password: password }
11
10
  describe 'single phone' do
12
11
  let(:phone) { '13928452841' }
13
12
  before do
@@ -31,5 +30,16 @@ describe "Tui3" do
31
30
  its([:code]) { should eql 0 }
32
31
  its([:message]) { should eql "操作成功!" }
33
32
  end
33
+ context 'invalid key' do
34
+ let(:phone) { '13928452841' }
35
+ let(:password) { '666666' }
36
+ before do
37
+ stub_request(:post, url).
38
+ with(body: {k: password, t: phone, c: content, p: '1', r: 'json'}).
39
+ to_return(body: 'invalid parameters' )
40
+ end
41
+ its([:success]) { should eql false }
42
+ its([:message]) { should eql "非法apikey:#{password}" }
43
+ end
34
44
  end
35
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: china_sms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - saberma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-03 00:00:00.000000000 Z
11
+ date: 2013-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler