Created
January 20, 2020 07:54
-
-
Save harshalbhakta/e5b9b7248654059d4e59d8f3e2455818 to your computer and use it in GitHub Desktop.
Msg91 Send SMS API v2 Sample Code
This file contains hidden or 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 'uri' | |
require 'net/http' | |
url = URI("https://api.msg91.com/api/v2/sendsms") | |
http = Net::HTTP.new(url.host, url.port) | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
request = Net::HTTP::Post.new(url) | |
request["authkey"] = 'xxxxxx' | |
request["content-type"] = 'application/json' | |
request.body = { | |
"sender" => "SOCKET", | |
"route" => "4", | |
"country" => "91", | |
"sms" => [ | |
{ | |
"message" => "Hello World 2!", | |
"to" => ["9898098980", "9898198981"] | |
} | |
] | |
}.to_json | |
response = http.request(request) | |
puts response.read_body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this, appreciate it.