Module: YunPian

Extended by:
YunPian
Included in:
YunPian
Defined in:
lib/yun-pian.rb,
lib/yun-pian/version.rb

Constant Summary collapse

SEND_URL =
'https://sms.yunpian.com/v2/sms/batch_send.json'
VERSION =
"0.1.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#apikeyObject

Returns the value of attribute apikey.



8
9
10
# File 'lib/yun-pian.rb', line 8

def apikey
  @apikey
end

Instance Method Details

#send(mobiles, message, options = {}) ⇒ Object

国内短信发送接口

1:准备参数 options(:apikey, :mobile, :message)
2:初始化 URI 对象
3:调用接口
4:解析返回的结果


17
18
19
20
21
22
23
24
25
# 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