Skip to content

Instantly share code, notes, and snippets.

@harshalbhakta
Created January 20, 2020 07:54
Show Gist options
  • Save harshalbhakta/e5b9b7248654059d4e59d8f3e2455818 to your computer and use it in GitHub Desktop.
Save harshalbhakta/e5b9b7248654059d4e59d8f3e2455818 to your computer and use it in GitHub Desktop.
Msg91 Send SMS API v2 Sample Code
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
@mankec
Copy link

mankec commented Jun 17, 2024

Thank you for this, appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment