Skip to content

Instantly share code, notes, and snippets.

@johannesl
Created March 25, 2014 13:56
Show Gist options
  • Save johannesl/9762369 to your computer and use it in GitHub Desktop.
Save johannesl/9762369 to your computer and use it in GitHub Desktop.
My first ever lines of Ruby code. It's fun to be able to send SMS from a new programming language after only 10 mins.. :-)
require 'net/http'
uri = URI('https://api.46elks.com/a1/SMS')
req = Net::HTTP::Post.new(uri)
req.basic_auth 'u12341234123412341234123412341234', 'ABCDABCDABCDABCDABCDABCDABCDABCD'
req.set_form_data(
:from => 'SenderName',
:to => '+46704508449',
:message => 'Login code 123456',
:flashsms => 'yes'
)
res = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request req
end
puts res.body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment