SendMessage

From CDYNE Wiki
Jump to: navigation, search

Send regular SMS or multimedia MMS message - to a single recipient or multiple recipients.

Contents

SendMessage Request

Parameter Name Data Type Sample Input Required
Attachments: Add attachments to message. Can be a URL or MediaID. String https://i.pinimg.com/736x/01/5.jpg OR 17772 FALSE
(When sending SMS message or Body parameter has a value for MMS message.)
Body: Message content String This is a sample message. FALSE
(When sending MMS message and Attachment parameter has a value.)
TRUE
(When sending SMS message.)
Subject: Subject line content of message. String CDYNE test FALSE
LicenseKey: Required to authenticate users invoking this Web Service.
Trial Key
Production Key
GUID f01d89fd-5155-5455-5585-e84ab8de8591 TRUE
From: DID/short code used to send message. String 15559080983 FALSE
To: Recipient number. String 15551234567 TRUE
Concatenate: Flag to indicate if concatenation headers should be added to messages that were broken into fragments. Boolean false FALSE
IsUnicode: Flag to indicate if message should be sent using Unicode encoding. Boolean false FALSE
PostbackUrl: Flag to indicate if message should be sent using Unicode encoding. String http://www.cdyne.com/postback.aspx FALSE
ReferenceID: Unique ID that can be set. String 123 FALSE
ScheduleDateTime: UTC date/time when message will send. DateTime 1999-05-31T11:20:00 FALSE
UseMMS: Flag when message includes multimedia content. Boolean true TRUE

SendMessage Response

Parameter Name Data Type Sample Output
Attachments: MediaID of attachment sent in message. String 12486
From: DID/short code used to send message. String 15559080983
MessageID: Unique ID set to outgoing message. GUID 1627aea5-8e0a-4371-9022-9b504344e724
MessageStatus: Status of outgoing message. String Ready
(Complete list of return codes.)
Sent Time: UTC date and time message sent. DateTime 1999-05-31T11:20:00
To: Recipient number. String 15551234567

JSON Request

The following is an example POST request using http://messaging.cdyne.com/Messaging.svc/SendMessage

{
	"Attachments": ["https://i.pinimg.com/736x/01/59/40/01594057534c60f94af3165f26d85629--monkey-humor-toddler-christmas.jpg"],
        "Body":"",
        "Subject":"",
        "LicenseKey": "f01d89fd-5155-5455-5585-e84ab8de8591",
        "From" : "15551234567",
	"To": ["15551234568"],
        "Concatenate":false, 
        "IsUnicode":false, 
	"PostBackUrl":"",
	"ReferenceID":"",
        "ScheduledDateTime":"\/Date(1239018869048)\/",
	"UseMMS": true
}

Ruby

require 'uri'
require 'net/http'
 
url = URI("http://messaging.cdyne.com/Messaging.svc/SendMessage")
 
http = Net::HTTP.new(url.host, url.port)
 
request = Net::HTTP::Post.new(url)
 
request["content-type"] = 'application/json'
 
request.body = '{
"Attachments": ["https://i.pinimg.com/736x/01/59/40/01594057534c60f94af3165f26d85629--monkey-humor-toddler-christmas.jpg"],
"Body":"",
"Subject":"",
"LicenseKey": "f01d89fd-5155-5455-5585-e84ab8de8591",
"From" : "15551234567",
"To": ["15551234568"],
"Concatenate":false,
"IsUnicode":false,
"PostBackUrl":"",
"ReferenceID":"",
"ScheduledDateTime":"\/Date(1239018869048)\/",
"UseMMS": true
}'

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

C#

/*http://messaging.cdyne.com/Messaging.svc?wsdl was added as Service Reference and given the name WSDL*/
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SendMessage.WSDL;
 
namespace SendMessage
{
class Program
{
static void Main(string[] args)
{
MessagingClient client = new MessagingClient("mms2wsHttpBinding");
OutgoingMessageRequest req = new OutgoingMessageRequest();
 
req.Attachments = new string[] {@"https://i.pinimg.com/736x/01/59/40/01594057534c60f94af3165f26d85629--monkey-humor-toddler-christmas.jpg"};
req.Body = "";
req.Subject = "";
req.LicenseKey = new Guid("f01d89fd-5155-5455-5585-e84ab8de8591");
req.From = "15559080983";
req.To = new string[] {"15551234567"};
req.Concatenate = false;
req.IsUnicode = false;
req.PostbackUrl = "";
req.ReferenceID = "";
req.ScheduledDateTime = new DateTime(2017, 10, 09, 14, 15, 0).ToUniversalTime();
req.UseMMS = true;
 
 
OutgoingMessageResponse[] resp = client.SendMessage(req);
 
foreach (var item in resp)
{
Console.WriteLine("MessageID: " + item.MessageID + Environment.NewLine +
"Message Status: " + item.MessageStatus + Environment.NewLine +
"To: " + item.To + Environment.NewLine +
"From: " + item.From + Environment.NewLine +
"UTC Time Sent: " + item.SentTime + Environment.NewLine +
"Attachments: " + item.Attachments);
}
 
Console.ReadLine();
}
}
}

VB.Net

'http://messaging.cdyne.com/Messaging.svc?wsdl was added as Service Reference and given the name WSDL
 
Imports SendMessage.WSDL
 
Module Module1
 
Sub Main()
 
Dim client As WSDL.MessagingClient = New MessagingClient("mms2wsHttpBinding")
 
Dim req As WSDL.OutgoingMessageRequest = New WSDL.OutgoingMessageRequest()
 
req.Attachments = New String() {"https://i.pinimg.com/736x/01/59/40/01594057534c60f94af3165f26d85629--monkey-humor-toddler-christmas.jpg"}
req.Body = ""
req.Subject = "Monkey"
req.LicenseKey = New Guid("f01d89fd-5155-5455-5585-e84ab8de8591")
req.From = "15559080983"
req.To = New String() {"15551234567"}
req.Concatenate = False
req.IsUnicode = False
req.PostbackUrl = "http://cdyne.com/postback.aspx"
req.ReferenceID = ""
req.ScheduledDateTime = New DateTime(2017, 10, 9, 14, 15, 0).ToUniversalTime()
req.UseMMS = True
 
Dim resp As OutgoingMessageResponse() = client.SendMessage(req)
 
For Each item In resp
 
Console.WriteLine("MessageID: " + Convert.ToString(item.MessageID) + Environment.NewLine +
"Message Status: " + Convert.ToString(item.MessageStatus) + Environment.NewLine +
"To: " + item.To + Environment.NewLine +
"From: " + item.From + Environment.NewLine +
"UTC Time Sent: " + Convert.ToString(item.SentTime) + Environment.NewLine +
"Attachments: " + item.Attachments)
Next
 
Console.ReadLine()
 
End Sub
 
End Module

PHP with cURL

<?php
 
$json='{
"Attachments":["https://i.pinimg.com/736x/01/59/40/01594057534c60f94af3165f26d85629--monkey-humor-toddler-christmas.jpg"],
"Body":"",
"Concatenate":false,
"From":"15559080983",
"IsUnicode":false,
"LicenseKey":"f01d89fd-5155-5455-5585-e84ab8de8591",
"PostbackUrl":"http://cdyne.com/postback.aspx",
"ReferenceID":"",
"ScheduledDateTime":"\/Date(1239018869048)\/",
"Subject":"",
"To":["15553096094"],
"UseMMS":true
}'
;
 
$url='http://messaging.cdyne.com/Messaging.svc/SendMessage';
$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);
 
$array = json_decode($result, true);
//print_r($json);
//print_r("\n\n\n\n");
 
print_r($array);
 
?>


VBScript

Dim cXML
cXML = "<OutgoingMessageRequest xmlns=""http://sms2.cdyne.com"">" & _
"<Attachments>" & _
"<string xmlns=""http://schemas.microsoft.com/2003/10/Serialization/Arrays"">https://i.pinimg.com/736x/01/59/40/01594057534c60f94af3165f26d85629--monkey-humor-toddler-christmas.jpg</string>" & _
"</Attachments>" & _
"<Body></Body>" & _
"<Concatenate>false</Concatenate>" & _
"<From>15559080983</From>" & _
"<IsUnicode>false</IsUnicode>" & _
"<LicenseKey>f01d89fd-5155-5455-5585-e84ab8de8591</LicenseKey>" & _
"<PostbackUrl></PostbackUrl>" & _
"<ReferenceID></ReferenceID>" & _
"<ScheduledDateTime>1999-05-31T11:20:00</ScheduledDateTime>" & _
"<Subject></Subject>" & _
"<To>" & _
"<string xmlns=""http://schemas.microsoft.com/2003/10/Serialization/Arrays"">15553096094</string>" & _
"</To>" & _
"<UseMMS>true</UseMMS>" & _
"</OutgoingMessageRequest>"
 
Dim oXMLHTTP
Set oXMLHTTP = CreateObject("Microsoft.XMLHTTP")
Set oDoc = CreateObject("MSXML2.DOMDocument")
Call oXMLHttp.Open("POST", "http://messaging.cdyne.com/Messaging.svc/SendMessage", False)
Call oXMLHttp.setRequestHeader("Content-Type", "text/xml")
Call oXMLHttp.send(cXML)
 
MsgBox oXMLHTTP.responseText
 
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fso, MyFile, FileName, TextLine
Set fso = CreateObject("Scripting.FileSystemObject")
FileName = "c:\Users\Desktop\MMS.txt"
Set MyFile = fso.OpenTextFile(FileName, ForWriting, True)
MyFile.WriteLine oXMLHttp.responseText
MyFile.Close
Set MyFile = fso.OpenTextFile(FileName, ForReading)
Do While MyFile.AtEndOfStream <> True
TextLine = MyFile.ReadLine
Loop
MyFile.Close
 
set request = nothing


JAVA

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
 
public final class SendMessage {
 
public static void main(String[] args) throws Exception {
String responseContent = "";
String response = "";
 
URL url = new URL("http://messaging.cdyne.com/Messaging.svc/SendMessage");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
 
StringBuilder sb = new StringBuilder("<OutgoingMessageRequest xmlns=\"http://sms2.cdyne.com\">");
sb.append("<Attachments>");
sb.append("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">https://i.pinimg.com/736x/01/59/40/01594057534c60f94af3165f26d85629--monkey-humor-toddler-christmas.jpg</string>");
sb.append("</Attachments>");
sb.append("<Body></Body>");
sb.append("<Concatenate>false</Concatenate>");
sb.append("<From>15559080983</From>");
sb.append("<IsUnicode>false</IsUnicode>");
sb.append("<LicenseKey>f01d89fd-5155-5455-5585-e84ab8de8591</LicenseKey>");
sb.append("<PostBackUrl></PostBackUrl>");
sb.append("<ReferenceID></ReferenceID>");
sb.append("<ScheduledDateTime>2013-01-15T20:53:00.608Z</ScheduledDateTime>");
sb.append("<Subject>Testing Java</Subject>");
sb.append("<To>");
sb.append("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">15553096094</string>");
sb.append("</To>");
sb.append("<UseMMS>true</UseMMS>");
sb.append("</OutgoingMessageRequest>");
 
connection.setRequestProperty("Content-Length", String.valueOf(sb.toString().length()));
connection.setRequestProperty("Content-Type", "text/xml");
connection.setRequestProperty("Connection", "Close");
connection.setRequestProperty("SoapAction", "");
connection.setRequestMethod("POST");
connection.setDoInput(true);
connection.setDoOutput(true);
 
PrintWriter pw = new PrintWriter(connection.getOutputStream());
pw.write(sb.toString());
pw.flush();
connection.connect();
 
System.out.println(sb.toString());
BufferedReader br;
 
if (connection.getResponseCode() == 200) {
br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
} else {
br = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
}
 
while ((responseContent = br.readLine()) != null) {
response += responseContent;
}
System.out.println(response);
}
}
Personal tools
Namespaces

Variants
Actions
Navigation
Tools

Trial Key