Example api code for Transactional SMS in ruby

Replace user, password, msisdn, sid and message accordingly.

 

1. Below is the sample code for ruby for Single Message:

require 'net/http'
require 'uri'

user = 'abc'
password = 'xyz'
msisdn = '919898xxxxxx'
sid = 'SenderId'
message = 'test message'
fl = '0'
gwid = '2'

url = URI.parse("http://sms.domainadda.com/vendorsms/pushsms.aspx?user=#{user}&password=#{password}&msisdn=#{msisdn}&sid=#{sid}&msg=#{URI.escape(message)}&fl=#{fl}&gwid=#{gwid}")

response = Net::HTTP.get_response(url)

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 'uri'
require 'net/http'

user = 'abc'
password = 'xyz'
msisdns = '919898xxxxxx,919898xxxxxx'
sid = 'SenderId'
message = 'test message'
fl = '0'
gwid = '2'

uri = URI.parse("http://sms.domainadda.com/vendorsms/pushsms.aspx?user=#{user}&password=#{password}&msisdn=#{msisdns}&sid=#{sid}&msg=#{URI.escape(message)}&fl=#{fl}&gwid=#{gwid}")

response = Net::HTTP.get_response(uri)

if response.is_a?(Net::HTTPSuccess)
puts 'API response: ' + response.body
else
puts 'Error sending request'
end

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Example api code for Transactional SMS in asp.net

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Transactional SMS in php

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Transactional SMS in java

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Transactional SMS in node.js

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Transactional SMS in python

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...