diff --git a/README.md b/README.md index 4efd818..d4cdb3d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,13 @@ # ChinaSMS 短信平台 Ruby 接口 +## 支持以下短信平台 + +所有短信平台都禁止发送私人短信,并要求在短信内容末尾加上签名后缀,如【19屋】 + +* [推立方](http://tui3.com/) 需要审核内容格式和签名,自动在短信加上签名后缀 +* [短信宝](http://www.smsbao.com/) +* [畅友网络](http://www.chanyoo.cn/) + ## 安装 加入以下代码到 Gemfile: diff --git a/lib/china_sms/service/tui3.rb b/lib/china_sms/service/tui3.rb new file mode 100644 index 0000000..fbed612 --- /dev/null +++ b/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 diff --git a/spec/china_sms_spec.rb b/spec/china_sms_spec.rb index 4248c8d..73aa017 100644 --- a/spec/china_sms_spec.rb +++ b/spec/china_sms_spec.rb @@ -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 } @@ -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