Module: ChinaSMS::Service::Yunpian
Constant Summary collapse
- URL =
"http://yunpian.com/v1/sms/tpl_send.json"- GET_URL =
"http://yunpian.com/v1/sms/get.json"
Instance Method Summary collapse
Instance Method Details
#get(options = {}) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/china_sms/service/yunpian.rb', line 20 def get = {} [:apikey] ||= [:password] except! , :username, :password, :company res = Net::HTTP.post_form(URI.parse(GET_URL), ) result res.body end |
#result(body) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/china_sms/service/yunpian.rb', line 27 def result body begin JSON.parse body rescue => e { code: 502, msg: "内容解析错误", detail: e.to_s } end end |
#to(phone, content, options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/china_sms/service/yunpian.rb', line 10 def to phone, content, = {} = parse_content content, [:company] [:tpl_id] ||= 2 [:apikey] ||= [:password] except! , :username, :password, :company .merge!({mobile: phone, tpl_value: }) res = Net::HTTP.post_form(URI.parse(URL), ) result res.body end |