Module: Textmarketer

Defined in:
lib/textmarketer.rb,
lib/textmarketer/version.rb

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.send(username, password, to, message, from) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/textmarketer.rb', line 6

def self.send username, password, to, message, from
	requested_url = 'http://api.textmarketer.co.uk/gateway/?option=xml' + "&username=" + username + "&password=" + password + "&to=" + to + "&message=" + URI.escape(message) + "&orig=" + URI.escape(from)
 url = URI.parse(requested_url)
 full_path = (url.query.blank?) ? url.path : "#{url.path}?#{url.query}"
 the_request = Net::HTTP::Get.new(full_path)
 the_response = Net::HTTP.start(url.host, url.port) { |http|
   http.request(the_request)
 }
 raise "Response was not 200, response was #{the_response.code}" if the_response.code != "200"
end