SMSv2 Ruby

From CDYNE Wiki for Web Services
Jump to: navigation, search

Ruby calling a WCF Webservice using REST and JSON.

SimpleSMSSend

  • Send a single message to a single number.
require 'net/http'
require 'URI'
 
puts URI.methods
 
url = URI.parse('http://sms2.cdyne.com/sms.svc/SimpleSMSsend?PhoneNumber=YourPhoneNumber&Message=HelloRubyWorld&LicenseKey=YourLicenseKey')
 
res = Net::HTTP.get_response(url)
 
data = res.body
 
puts data

AdvancedSMSSend

  • Send different messages to different numbers with one method.
require 'net/http'
 
http = Net::HTTP.new('sms2.cdyne.com',80)
 
path = '/sms.svc/AdvancedSMSsend'
 
data = '{
		"LicenseKey":"YourLicenseKey",
		"SMSRequests":[{
			"AssignedDID":""
			, "Message":"Hello Ruby World"
			, "PhoneNumbers":["YourPhoneNumber"]
			, "ReferenceID":""
			, "StatusPostBackURL":""
		}]
	}'
 
headers = {
	'Content-Type' => 'application/json'
}
 
resp, data = http.post(path, data, headers)
 
puts data
Personal tools
Toolbox





Trial Key