AdvancedSMSSend

From CDYNE Wiki
Jump to: navigation, search

Immediately send or schedule a single text message to multiple phone numbers, or individual messages to multiple recipients. The AdvancedSMSSend method includes a [PostBackURL] parameter. SMS Notify! uses DIDs or short codes assigned to your account license key to send MT text messages and receive MO text messages.

Contents

AdvancedSMSSend Request

Parameter Name Data Type Sample Input
Concatenate: Flag to indicate if concatenation headers should be added to messages that were broken into fragments. (Not supported by all devices.). Boolean False
IsUnicode: Flag to indicate if message should be sent using Unicode encoding (UCS-2). Boolean False
LicenseKey: Required to authenticate users invoking this Web Service.

Trial Key. Production Key.

String F01d89fd-5155-5455-5585-e84ab8de8591
SMSRequests: An array of SMS Requests shown below.
SMSRequest

AssignedDID: Input the number of an assigned DID (Contact CDYNE to request an assigned DID).

Message: Message to send to phone number

PhoneNumbers: Input phone number to send SMS text to.

ReferenceID: A unique ID that can be set per SMS message.

ScheduledDateTime: Input desired UTC time to send the message.

StatusPostBackURL: Input to receive posts to your server when SMS has been sent, and when response is received.


String

String

Array (String)

String

Datetime

String


17575449510

This is a sample message from SMS Notify!

17575551234;17575554321

CDYNE Test

009-03-23T15:02:30.05Z

Server URL

XML Request

HTTP Method: POST

Url: http://sms2.cdyne.com/sms.svc/help/operations/AdvancedSMSsend

Url: https://sms2.cdyne.com/sms.svc/SecureREST/AdvancedSMSsend

The following is an example request Xml body:


<SMSAdvancedRequest xmlns="http://schemas.datacontract.org/2004/07/SmsWS">
  <Concatenate>true</Concatenate>
  <IsUnicode>true</IsUnicode>   //Optional - If <IsUnicode>true</IsUnicode> max message character limit is 70.
  <LicenseKey>1627aea5-8e0a-4371-9022-9b504344e724</LicenseKey>
  <SMSRequests>
    <SMSRequest xmlns="http://sms2.cdyne.com">
      <AssignedDID>String content</AssignedDID>
      <Message>String content</Message>
      <PhoneNumbers>
        <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">String content</string>
        <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">String content</string>
      </PhoneNumbers>
      <ReferenceID>String content</ReferenceID>
      <ScheduledDateTime>1999-05-31T11:20:00</ScheduledDateTime>
      <StatusPostBackURL>String content</StatusPostBackURL>
    </SMSRequest>
    <SMSRequest xmlns="http://sms2.cdyne.com">
      <AssignedDID>String content</AssignedDID>
      <Message>String content</Message>
      <PhoneNumbers>
        <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">String content</string>
        <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">String content</string>
      </PhoneNumbers>
      <ReferenceID>String content</ReferenceID>
      <ScheduledDateTime>1999-05-31T11:20:00</ScheduledDateTime>
      <StatusPostBackURL>String content</StatusPostBackURL>
    </SMSRequest>
  </SMSRequests>
</SMSAdvancedRequest>

Json Request

HTTP Method: POST

Url: http://sms2.cdyne.com/sms.svc/help/operations/AdvancedSMSsend

Url: https://sms2.cdyne.com/sms.svc/SecureREST/AdvancedSMSsend

The following is an example request Json body:


{
        "Concatenate":true,  //Optional.
        "IsUnicode":true,  //Optional.  If "IsUnicode":true, max message character length is 70.
        "LicenseKey":"1627aea5-8e0a-4371-9022-9b504344e724",
	"SMSRequests":[{
		"AssignedDID":"String content",
		"Message":"String content",
		"PhoneNumbers":["String content"],
		"ReferenceID":"String content",
		"ScheduledDateTime":"\/Date(928164000000)\/",
		"StatusPostBackURL":"String content"
	}]
}

AdvancedSMSSend Response


Parameter Name Data Type Sample Output
Cancelled: Returns true or false if the SMS message has been cancelled. Boolean False
MessageID: Returns unique Guid ID for every SMS message sent. Guid B01d89fd-5155-5455-5585-e84ab8de8591
Queued: Returns true or false if the SMS message has been queued. Boolean True
ReferenceID: Returns a unique ID that is assigned during request input. (Not a required Input) String CDYNE Test
SMSError: Returns a string indicating if there was an error sending the SMS message.
  • NoError
  • STOPfromPhoneNumber
  • LicenseKeyInvalid
  • PhoneNumberInvalid
  • MessageInvalid
  • ScheduledDateTimeIsNotUTC
  • InvalidAssignedDID
  • NotFound (Occurs for Invalid MessageID)
  • InternalError
  • ContactCdyneAccountSuspended
String NoError
SMSIncomingMessages: Returns null when part of a Send response. Null Null
Sent: Returns true or false if the SMS message has been sent to the carrier. Boolean False
SentDateTime: Returns the UTC Date and Time of when the message was sent. Datetime 0001-01-01T00:00:00

XML Response

The following is an example response Xml body:


<ArrayOfSMSResponse xmlns="http://sms2.cdyne.com">
  <SMSResponse>
    <Cancelled>true</Cancelled>
    <MessageID>1627aea5-8e0a-4371-9022-9b504344e724</MessageID>
    <Queued>true</Queued>
    <ReferenceID>String content</ReferenceID>
    <SMSError>NoError</SMSError>
    <SMSIncomingMessages i:nil="true" />
    <Sent>true</Sent>
    <SentDateTime>1999-05-31T11:20:00</SentDateTime>
  </SMSResponse>
  <SMSResponse>
    <Cancelled>true</Cancelled>
    <MessageID>1627aea5-8e0a-4371-9022-9b504344e724</MessageID>
    <Queued>true</Queued>
    <ReferenceID>String content</ReferenceID>
    <SMSError>NoError</SMSError>
    <SMSIncomingMessages i:nil="true" />
    <Sent>true</Sent>
    <SentDateTime>1999-05-31T11:20:00</SentDateTime>
  </SMSResponse>
</ArrayOfSMSResponse>

Json Response

The following is an example response Json body:


[{
	"Cancelled":true,
	"MessageID":"1627aea5-8e0a-4371-9022-9b504344e724",
	"Queued":true,
	"ReferenceID":"String content",
	"SMSError":0,
	"SMSIncomingMessages":null,
	"Sent":true,
	"SentDateTime":"\/Date(928164000000-0400)\/"
}]

AdvancedSMSSend Code Examples

CSharp

Using as a Service Reference(.NET Framework 3.5+)

Add a service reference to your project: http://sms2.cdyne.com/sms.svc?wsdl

IsmsClient client = new IsmsClient("sms2wsHttpBinding");
SMSAdvancedRequest advReq = new SMSAdvancedRequest();
advReq.Concatenate = true; //Optional.
advReq.IsUnicode = true; //Optional. If advReq.IsUnicode = true; max message character length is 70.
advReq.LicenseKey = new Guid("YOUR LICENSE KEY");
List<SMSRequest> reqs = new List<SMSRequest>();
SMSRequest req = new SMSRequest();
req.Message = "Test Advanced SMS"; //Single-line message.
//req.Message = "SMS Advanced" + "\n" + "Line 1" + "\n" + "Line 2"; //Multi-line message
req.PhoneNumbers = new string[] {"17575449510", "17579510544"}; //You could send the same message to multiple phone numbers. (You will get back a response packet per phone number.)
req.ReferenceID = "2863172"; //Will return with responses. (Optional)
req.StatusPostBackURL = "http://www.cdyne.com/postback.asmx"; //(Optional)
req.ScheduledDateTime = new DateTime(2012, 09, 25, 14, 15, 0).ToUniversalTime();
//ScheduledDateTime Format is Year, Month, Date Hour, Minutes, Seconds. The time can be set in your local time zone as it is converted to UTC.
req.AssignedDID = "1555123456"; //Assigned DID. (Optional)
reqs.Add(req);
// add more requests here...
advReq.SMSRequests = reqs.ToArray(); //Adds the array of requests to the SMSAdvancedRequest object.
SMSResponse[] smsResponses = client.AdvancedSMSsend(advReq);
foreach (var item in smsResponses)
{
Console.WriteLine(item.MessageID + " " + item.SMSError);
}
Console.ReadLine();
client.Close();

VB.NET

Add a service reference to http://sms2.cdyne.com/sms.svc?wsdl

Imports AdvancedSMS.WSDL
Module Module1
Sub Main()
Dim client As WSDL.IsmsClient = New WSDL.IsmsClient("sms2wsHttpBinding")
Dim advReq As New WSDL.SMSAdvancedRequest()
Dim smsReqs As List(Of WSDL.SMSRequest) = New List(Of WSDL.SMSRequest)
Dim req As WSDL.SMSRequest = New WSDL.SMSRequest()
Dim phoneNumbers As List(Of String) = New List(Of String)
advReq.Concatenate = true 'Optional.
advReq.IsUnicode = true 'Optional. If advReq.IsUnicode = true max message character length is 70.
advReq.LicenseKey = New Guid("YOUR LICENSE KEY")
req.Message = "VB.NET SMS Advanced" 'Single line message
'req.Message = "VB.NET SMS Advanced" & Environment.NewLine & "Line 1" & Environment.NewLine & "Line 2" 'Multi-line message
req.PhoneNumbers = New String() {"17575449510", "1555123456"}
req.ScheduledDateTime = New DateTime(2011, 8, 2, 13, 10, 0).ToUniversalTime
'ScheduledDateTime Format is Year, Month, Date Hour, Minutes, Seconds. The time can be set in your local time zone as it is converted to UTC.
req.AssignedDID = "ASSIGNED DID NUMBER HERE" 'Optional
smsReqs.Add(req)
advReq.SMSRequests = smsReqs.ToArray()
Dim resp As WSDL.SMSResponse() = client.AdvancedSMSsend(advReq)
For Each item In resp
Console.WriteLine(Convert.ToString(item.MessageID) & " " & "SMS Error: " & Convert.ToString(item.SMSError))
Next
Console.ReadLine()
client.Close()
End Sub

VBScript

Sending an AdvancedSMSsend request by passing XML with an http object in VBScript

Dim thexml
 
'The xml may look sloppy, but it must be a single line to work.
'Look here http://sms2.cdyne.com/sms.svc/help/operations/AdvancedSMSsend for a sample xml packet in a more readable format.
'For this sample to work, replace all the (your value here) in thexml with the values you wish to use.

thexml = "<SMSAdvancedRequest xmlns=""http://schemas.datacontract.org/2004/07/SmsWS""> <Concatenate>true</Concatenate><IsUnicode>true</IsUnicode>
<LicenseKey>(Your License Key)</LicenseKey><SMSRequests><SMSRequest xmlns="
"http://sms2.cdyne.com""><AssignedDID></AssignedDID><Message>(Your Message)</Message>
<PhoneNumbers><string xmlns="
"http://schemas.microsoft.com/2003/10/Serialization/Arrays"">(Your Number</string></PhoneNumbers><ReferenceID></ReferenceID>
<StatusPostBackURL></StatusPostBackURL></SMSRequest></SMSRequests></SMSAdvancedRequest>"

 
'<ScheduledDateTime>1999-05-31T11:20:00</ScheduledDateTime>
'If you wish for the message to be sent at a future datetime include this parameter.
'Note the ScheduledDateTime must be in UTC format.

dim xmlHttp
 
set xmlHttp = createobject("Microsoft.XMLHTTP")
 
call xmlHttp.open("POST", "http://sms2.cdyne.com/sms.svc/AdvancedSMSsend",false)
call xmlHttp.setRequestHeader("Content-Type","text/xml")
call xmlHttp.send(thexml)
 
document.write(xmlHttp.responseText)

PHP

  • Send SMS messages using SOAP client
  • Send different messages to different numbers with one method.
 
 
$client = new SoapClient('http://sms2.cdyne.com/sms.svc?wsdl');
 
$lk = '(your license key here)';
$unicode = true;
$concat = true;
 
$PhoneNumbersArray1 = array('0123456789', '4567891230');
$PhoneNumbersArray2 = array('1234567890', '7652212120');
 
$Message1 = 'Hello World';
$Message2 = 'Goodbye World';
 
 
$RequestArray = array(
			array(
				'AssignedDID'=>'',  //If you have a Dedicated Line, you would assign it here.
				'Message'=>$Message1,   
				'PhoneNumbers'=>$PhoneNumbersArray1,
				'ReferenceID'=>'',  //User defined reference, set a reference and use it with other SMS functions.
				//'ScheduledDateTime'=>'2010-05-06T16:06:00Z',  //This must be a UTC time.  Only Necessary if you want the message to send at a later time.
				'StatusPostBackURL'=>''  //Your Post Back URL for responses.
			)
			,array(
				'AssignedDID'=>'',
				'Message'=>$Message2,
				'PhoneNumbers'=>$PhoneNumbersArray2,
				'ReferenceID'=>'',
				'ScheduledDateTime'=>'2010-05-06T16:06:00Z',
				'StatusPostBackURL'=>''
			)
	);
 
$request = new AdvancedCallRequestData($lk,$RequestArray,$unicode,$concat);
//print_r($request);
 
$result = $client->AdvancedSMSsend($request);
print_r($result);
 
class AdvancedCallRequestData {
  public $AdvancedRequest;
 
   function AdvancedCallRequestData($lk,$requests, $unicode, $concat) { 
            $this->AdvancedRequest = array();
	    $this->AdvancedRequest['Concatenate'] = $concat;
	    $this->AdvancedRequest['IsUnicode'] = $unicode;
            $this->AdvancedRequest['LicenseKey'] = $licensekey;
            $this->AdvancedRequest['SMSRequests'] = $requests;  }  
}
 
 

PHP with cURL

  • Send SMS messages using cURL
 
 
 //Request parameters in JSON format
$json='{
                "Concatenate":"true",  //Optional.
                "IsUnicode":"true",  //Optional. If "IsUnicode":"true" max message character limit is 70.
                "LicenseKey":"LicenseKey",
                "SMSRequests":[{
		"AssignedDID":"",
		"Message":"Hello there",
		"PhoneNumbers":["PhoneNumber"],
		"ReferenceID":"",
		"ScheduledDateTime":"\/Date(1239018869048)\/",
		"StatusPostBackURL":""
                                                            }]
}';
 
//Method
$url='http://sms2.cdyne.com/sms.svc/AdvancedSMSsend';
 
$cURL = curl_init();
 
curl_setopt($cURL,CURLOPT_URL,$url);
curl_setopt($cURL,CURLOPT_POST,true);
curl_setopt($cURL,CURLOPT_POSTFIELDS,$json);
curl_setopt($cURL,CURLOPT_RETURNTRANSFER, true);  
curl_setopt($cURL, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Accept: application/json'));
//If you desire your results in xml format, use the following line for your httpheaders and comment out the httpheaders code line above.
//curl_setopt($cURL, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 
$result = curl_exec($cURL);
 
curl_close($cURL);
 
print_r($result)
 
 

Ruby

require 'uri'
require 'net/http'
 
url = URI("http://sms2.cdyne.com/sms.svc/AdvancedSMSSend")
 
http = Net::HTTP.new(url.host, url.port)
 
request = Net::HTTP::Post.new(url)
 
request["content-type"] = 'application/json'
 
request.body = '{
"Concatenate": false,
"IsUnicode": false,
"LicenseKey":"F01d89fd-5155-5455-5585-e84ab8de8591",
"SMSRequests":[{
"AssignedDID":"",
"Message":"CDYNE test message.",
"PhoneNumbers":["17575449510"],
"ReferenceID":"123",
"StatusPostBackURL":"www.yourpostbackurlhere.com",
"ScheduledDateTime":"\/Date(928164000000)\/"}]
}'

 
response = http.request(request)
 
puts response.read_body

RubyOnRails

Ruby On Rails calling a WCF Webservice using REST and JSON.

def deliver_sms(phone,message)
payload ={}
phone_numbers =[phone]
smsrequest = {"Message" => message ,"PhoneNumbers" => phone_numbers, "AssignedDID" => 'MYDID'}
smsrequests =[smsrequest]
payload = {}
payload["Concatenate"] = "true" #Optional.
payload["IsUnicode"] = "true" #Optional. If payload["IsUnicode"] = "true" max message character limit is 70.
payload["LicenseKey"] ="KEY"
payload["SMSRequests"] =smsrequests
http = Net::HTTP.new("sms2.cdyne.com",80)
header ={}
header['Content-Type'] ='application/json'
req = Net::HTTP::Post.new("/sms.svc/AdvancedSMSsend",header)
puts "===================SMS====================="
puts payload.to_json
puts "================SMS========================"
req.body =payload.to_json
response =http.request(req)
puts response
end

cURL

Sending an SMS via cURL is easy to do. You can download cURL from http://curl.haxx.se

The following example allows you to call a .NET WCF service via REST and JSON using cURL:

curl -H "Content-Type: application/json" -d '{
"Concatenate":"true",  #Optional.
"IsUnicode":"true",  #Optional.  If "IsUnicode":"true" max message character limit is 70.
"LicenseKey":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"SMSRequests":[{"AssignedDID":"",
"Message":"From Curl",
"PhoneNumbers":["XXXXXXXXXX","XXXXXXXXXX"],
"ReferenceID":"ReqFromCurl",
"StatusPostBackURL":""}]}' 
http://sms2.cdyne.com/sms.svc/AdvancedSMSsend

JAVA

Example provided by Uday Sappa with http://www.inhode.com

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
 
public final class SMSNotifyAdvanced {
public static void main(String[] args) throws Exception
{
String responseContent="";
String response="";
 
URL url = new URL("http://sms2.cdyne.com/sms.svc/AdvancedSMSsend");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
 
StringBuilder sb = new StringBuilder("<SMSAdvancedRequest xmlns=\"http://schemas.datacontract.org/2004/07/SmsWS\">");
sb.append("<Concatenate>true</Concatenate>"); //Optional.
sb.append("<IsUnicode>true</IsUnicode>"); //Optional. If sb.append("<IsUnicode>true</IsUnicode>") max message character limit is 70.
sb.append("<LicenseKey>YOUR LICENSE KEY</LicenseKey>");
sb.append("<SMSRequests>");
sb.append("<SMSRequest xmlns=\"http://sms2.cdyne.com\">");
sb.append("<AssignedDID>YOUR DID</AssignedDID>"); //OPTIONAL
sb.append("<Message>Test Message</Message>");
sb.append("<PhoneNumbers>");
sb.append("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">15551234567</string>");
sb.append("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">15551234567</string>");
sb.append("</PhoneNumbers>");
sb.append("<ReferenceID>1234</ReferenceID>");
sb.append("<ScheduledDateTime>2013-01-15T20:53:00Z</ScheduledDateTime>");
sb.append("<StatusPostBackURL>http://www.postbackurl.com</StatusPostBackURL>"); //OPTIONAL
sb.append("</SMSRequest>");
sb.append("</SMSRequests>");
sb.append("</SMSAdvancedRequest>");
 
connection.setRequestProperty("Content-Length", String.valueOf(sb.toString().length()));
connection.setRequestProperty("Content-Type", "text/xml");
connection.setRequestProperty("Connection", "Close");
connection.setRequestProperty("SoapAction", "");
connection.setDoOutput(true);
 
PrintWriter pw = new PrintWriter(connection.getOutputStream());
pw.write(sb.toString());
pw.flush();
 
connection.connect();
 
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
 
while ((responseContent = in.readLine()) != null)
{
response += responseContent;
}
System.out.println(response);
}
}

Perl

http://search.cpan.org/~revmischa/Net-SMS-CDYNE-0.04/lib/Net/SMS/CDYNE.pm

Personal tools
Namespaces

Variants
Actions
Navigation
Tools

Trial Key