Replace user, password, msisdn, sid and message accordingly.
1. Below is the sample code for ruby for Single Message:
require 'uri'
require 'net/http'
user = 'abc'
password = 'xyz'
msisdn = '919898xxxxxx'
sid = 'SenderId'
message = 'test message'
fl = '0'
url = URI("http://sms.domainadda.com/vendorsms/pushsms.aspx?user=#{user}&password=#{password}&msisdn=#{msisdn}&sid=#{sid}&msg=#{URI.encode_www_form_component(message)}&fl=#{fl}")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
if response.is_a?(Net::HTTPSuccess)
puts 'API response: ' + response.body
else
puts 'Error sending request'
end
2. Below is the sample code for ruby for Multiple Messages:
require 'rest-client'
user = 'abc'
password = 'xyz'
msisdns = '919898xxxxxx,919898xxxxxx' # Comma-separated list of phone numbers
sid = 'SenderId'
message = 'test message'
fl = '0'
url = 'http://sms.domainadda.com/vendorsms/pushsms.aspx'
params = {
user: user,
password: password,
msisdn: msisdns,
sid: sid,
msg: message,
fl: fl
}
begin
response = RestClient.post(url, params)
puts 'API response: ' + response.body
rescue RestClient::ExceptionWithResponse => e
puts 'Error sending request: ' + e.response.body
end