Skip to content

Commit

Permalink
suppport tui3
Browse files Browse the repository at this point in the history
  • Loading branch information
saberma committed Jun 30, 2013
1 parent 920909d commit 6b90eed
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
@@ -1,5 +1,13 @@
# ChinaSMS 短信平台 Ruby 接口

## 支持以下短信平台

所有短信平台都禁止发送私人短信,并要求在短信内容末尾加上签名后缀,如【19屋】

* [推立方](http://tui3.com/) 需要审核内容格式和签名,自动在短信加上签名后缀
* [短信宝](http://www.smsbao.com/)
* [畅友网络](http://www.chanyoo.cn/)

## 安装

加入以下代码到 Gemfile:
Expand Down
18 changes: 18 additions & 0 deletions lib/china_sms/service/tui3.rb
@@ -0,0 +1,18 @@
module ChinaSMS
module Service
# http://tui3.com/
module Tui3
extend self
def to(phone, content)
url = "http://tui3.com/api/send/"
res = Net::HTTP.post_form(URI.parse(url), k: ChinaSMS.password, t: phone, c: URI::encode(content), p: 1, r: 'json')
result res.body
#{"err_code":2,"err_msg":"k,\u975e\u6cd5apikey:666666","server_time":"2013-06-30 20:17:36"}
end

def result(json)
json
end
end
end
end
6 changes: 4 additions & 2 deletions spec/china_sms_spec.rb
Expand Up @@ -2,7 +2,8 @@

describe "ChinaSMS" do
#let(:service) { :smsbao }
let(:service) { :chanyoo }
#jlet(:service) { :chanyoo }
let(:service) { :tui3 }
let(:password) { '666666' }
subject { ChinaSMS }
before { ChinaSMS.use service, username: 'saberma', password: password }
Expand All @@ -11,7 +12,8 @@
end
describe "#to" do
it 'should be success' do
result = subject.to('13928452841', '深圳 Rubyist 活动时间变更到明天下午 7:00,请留意。【19屋】')
#result = subject.to('13928452841', '深圳 Rubyist 活动时间变更到明天下午 7:00,请留意。【19屋】')
result = subject.to('13928452841', '活动通知:深圳 Rubyist 活动时间变更到明天下午 7:00,请留意。')
puts result
end
end
Expand Down

0 comments on commit 6b90eed

Please sign in to comment.