Module: Luosimao::Message
- Defined in:
- lib/luosimao/message.rb
Constant Summary collapse
- SEND_URL =
"https://sms-api.luosimao.com/v1/send.json"
Class Method Summary collapse
Class Method Details
.to(phone, content) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/luosimao/message.rb', line 7 def self.to(phone, content) url = URI.parse SEND_URL post = Net::HTTP::Post.new(url.path) post.basic_auth(Luosimao.username, Luosimao.key) post.set_form_data({mobile: phone, message: "#{content}#{Luosimao.brand}"}) https = Net::HTTP.new(url.host, url.port) https.use_ssl = true response = https.start {|socket| socket.request(post)} JSON.parse response.body end |