Created
March 25, 2014 13:56
-
-
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.. :-)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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