Sidebar Menu

ReadIncomingMessages

Read incoming messages - you can view new or all incoming messages.

Request Parameters

Parameter Name Data Type Sample Input Required
EndDate: UTC date and time of most recent incoming message. DateTime 1999-05-31T11:20:00 FALSE
IncomingMessageID: Unique ID assigned to incoming message. GUID 1627aea5-8e0a-4371-9022-9b504344e724 FALSE
LicenseKey: License key used to receive incoming message
Trial Key
Production Key
GUID f01d89fd-5155-5455-5585-e84ab8de8591 TRUE
OutgoingMessageID: Unique ID of outgoing message. GUID 1627aea5-8e0a-4371-9022-9b504344e724 FALSE
PageNumber: Number of page where incoming message is located. Int 0 FALSE
PageSize: Number of incoming messages shown on page. Int 0 FALSE
ReferenceID: Unique ID that can be set. String 123 FALSE
StartDate: UTC date and time of earliest incoming message received. DateTime 1999-05-31T11:20:00 FALSE
UnreadMessagesOnly: You can choose to view all incoming messages or only incoming messages that are unread. Boolean false FALSE

Response

Parameter Name Data Type Sample Output
Attachment: MediaID of attachment sent in message. String 12486
From: DID/short code used to send message. String 15559080983
IncomingMessageID: Unique ID assigned to incoming message. GUID 1627aea5-8e0a-4371-9022-9b504344e724
OutgoingMessageID: Unique ID assigned to outgoing message. GUID 1627aea5-8e0a-4371-9022-9b504344e724
Payload: Incoming message content. String Thank you for your message
ReceivedDate: UTC date and time incoming message was received. DateTime 1999-05-31T11:20:00
Subject: Subject of incoming message. String Reply

Code Samples

{
	"EndDate":"\/Date(1506973090870+0000)\/",
	"LicenseKey":"f01d89fd-5155-5455-5585-e84ab8de8591",
        "PageNumber": 0,
        "PageSize": 0,
        "ReferenceID": "",
	"StartDate":"\/Date(1506973090870+0000)\/",
	"UnreadMessagesOnly":false
}
>

/*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 ReadIncomingMessages.WSDL;

namespace ReadIncomingMessages
{
    class Program
    {
        static void Main(string[] args)
        {
            MessagingClient client = new MessagingClient("mms2wsHttpBinding");
            IncomingMessageCriteria incoming = new IncomingMessageCriteria();

            incoming.EndDate = new DateTime(2017, 10, 06, 17, 00, 0).ToUniversalTime();
            incoming.IncomingMessageID = new Guid();
            incoming.LicenseKey = new Guid("f01d89fd-5155-5455-5585-e84ab8de8591");
            incoming.OutgoingMessageID = new Guid();
            incoming.PageNumber = 0;
            incoming.PageSize = 0;
            incoming.ReferenceID = "";
            incoming.StartDate = new DateTime(1990, 10, 01, 14, 15, 0).ToUniversalTime();
            incoming.UnreadMessagesOnly = false;

            IncomingMessageResponse[] resp = client.ReadIncomingMessages(incoming);

            if (resp.Length > 0)
            {
                foreach (var item in resp)
                {
                    Console.WriteLine("Incoming MessageID: " + item.IncomingMessageID + Environment.NewLine +
                                 "Outgoing MessageID: " + item.OutgoingMessageID + Environment.NewLine +
                                 "To: " + item.To + Environment.NewLine +
                                 "From: " + item.From + Environment.NewLine +
                                 "UTC Time Received: " + item.ReceivedDate + Environment.NewLine +
                                 "Message Subject: " + item.Subject + Environment.NewLine +
                                 "Message Text: " + item.Payload);

                    if (item.Attachments != null)
                    {
                        foreach (var media in item.Attachments)
                        {
                            Console.WriteLine("Attachments: " + media);
                        }
                    }

                    else Console.WriteLine("Attachments: No media.");

                    Console.WriteLine("UDH Info: " + item.Udh);
                }
            }
             
             Console.ReadLine();
        }
    }
}
>

'http://messaging.cdyne.com/Messaging.svc?wsdl was added as Service Reference and given the name WSDL

Imports ReadIncomingMessages.WSDL

Module Module1

    Sub Main()

        Dim client As WSDL.MessagingClient = New MessagingClient("mms2wsHttpBinding")

        Dim req As New WSDL.IncomingMessageCriteria()

        req.EndDate = New DateTime(2017, 10, 6, 17, 0, 0).ToUniversalTime()
        req.IncomingMessageID = New Guid()
        req.LicenseKey = New Guid("f01d89fd-5155-5455-5585-e84ab8de8591")
        req.OutgoingMessageID = New Guid()
        req.PageNumber = 0
        req.PageSize = 0
        req.ReferenceID = ""
        req.StartDate = New DateTime(1990, 10, 1, 14, 15, 0).ToUniversalTime()
        req.UnreadMessagesOnly = False

        Dim resp As IncomingMessageResponse() = client.ReadIncomingMessages(req)

        If resp.Length > 0 Then

            For Each item In resp

                Console.WriteLine("Incoming MessageID: " + Convert.ToString(item.IncomingMessageID) + Environment.NewLine +
                                 "Outgoing MessageID: " + Convert.ToString(item.OutgoingMessageID) + Environment.NewLine +
                                 "To: " + item.To + Environment.NewLine +
                                 "From: " + item.From + Environment.NewLine +
                                 "UTC Time Received: " + Convert.ToString(item.ReceivedDate) + Environment.NewLine +
                                 "Message Subject: " + item.Subject + Environment.NewLine +
                                 "Message Text: " + item.Payload + Environment.NewLine +
                                "UDH Info: " + Convert.ToString(item.Udh))

                If item.Attachments IsNot Nothing Then

                    For Each attach In item.Attachments

                        Console.WriteLine("Attachments: " + Convert.ToString(attach))

                    Next

                    Console.WriteLine()

                Else Console.WriteLine("Attachments: No media.")

                    Console.WriteLine()

                End If

            Next

        End If

        Console.ReadLine()

    End Sub

End Module
>
<?php

$json='{
	"EndDate":"\/Date(1506973090870+0000)\/",
	"LicenseKey":"f01d89fd-5155-5455-5585-e84ab8de8591",
	"StartDate":"\/Date(1506973090870+0000)\/",
	"UnreadMessagesOnly":false
}';

$url='http://messaging.cdyne.com/Messaging.svc/ReadIncomingMessages';
$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);

?>
>

Dim cXML
cXML = "<IncomingMessageCriteria xmlns=""http://sms2.cdyne.com"">" & _
  "<EndDate>2017-10-31T11:20:00</EndDate>" & _
  "<LicenseKey>f01d89fd-5155-5455-5585-e84ab8de8591</LicenseKey>" & _
  "<StartDate>2017-10-01T11:20:00</StartDate>" & _
  "<UnreadMessagesOnly>false</UnreadMessagesOnly>" & _
  "</IncomingMessageCriteria>"

Dim oXMLHTTP
Set oXMLHTTP = CreateObject("Microsoft.XMLHTTP")
Set oDoc = CreateObject("MSXML2.DOMDocument")
Call oXMLHttp.Open("POST", "http://messaging.cdyne.com/Messaging.svc/ReadIncomingMessages", 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
require 'uri'
require 'net/http'

url = URI("http://messaging.cdyne.com/Messaging.svc/ReadIncomingMessages")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)

request["content-type"] = 'application/json'

request.body = '{
"EndDate":"\/Date(1506973090870+0000)\/",
"LicenseKey":"f01d89fd-5155-5455-5585-e84ab8de8591",
"PageNumber": 0,
"PageSize": 0,
"ReferenceID": "",
"StartDate": "\/Date(1506973090870+0000)\/",
"UnreadMessagesOnly": false}'

response = http.request(request)

puts response.read_body
gets response.read_body
>

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;

public final class ReadIncomingMessages {

    public static void main(String[] args) throws Exception {
        String responseContent = "";
        String response = "";

        URL url = new URL("http://messaging.cdyne.com/Messaging.svc/ReadIncomingMessages");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();

        StringBuilder sb = new StringBuilder("<IncomingMessageCriteria xmlns=\"http://sms2.cdyne.com\">");
        sb.append("<EndDate>2017-10-31T11:20:00</EndDate>");
        sb.append("<LicenseKey>f01d89fd-5155-5455-5585-e84ab8de8591</LicenseKey>");
        sb.append("<StartDate>2017-10-01T11:20:00</StartDate>");
        sb.append("<UnreadMessagesOnly>false</UnreadMessagesOnly>");
        sb.append("</IncomingMessageCriteria>");

        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);
    }
}