Class: ExetelSms::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/client.rb

Class Method Summary collapse

Class Method Details

.request(url) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/client.rb', line 11

def request(url)
  uri = URI.parse(url)
  h = Net::HTTP.new(uri.host, uri.port)
  h.use_ssl = true
  h.verify_mode = OpenSSL::SSL::VERIFY_NONE
  #h.set_debug_output $stderr
  body = ''
  h.start do |http|
    response = http.request_get(uri.request_uri)
    body = response.body
  end
  raise "No body" unless body && body =~ /|/
  body.chomp.gsub(/<br>$/i, '').split('|').map {|str| str.strip }
end