module YunPian
Constants
- SEND_URL
- VERSION
Attributes
apikey[RW]
Public Instance Methods
send(mobiles, message, options = {})
click to toggle source
国内短信发送接口
1:准备参数 options(:apikey, :mobile, :message) 2:初始化 URI 对象 3:调用接口 4:解析返回的结果
# File lib/yun-pian.rb, line 17 def send(mobiles, message, options = {}) options[:apikey] ||= YunPian.apikey options.merge!({ mobile: mobiles, text: message }) uri = URI SEND_URL res = Net::HTTP.post_form(uri, options) result res.body end
Private Instance Methods
result(body)
click to toggle source
# File lib/yun-pian.rb, line 27 def result(body) JSON.parse body rescue JSON::ParserError => e { code: 502, msg: '内容解析错误', detail: e.to_s } end