GetMessageStatus

From CDYNE Wiki
Jump to navigation Jump to search

The GetMessageStatus method uses the MessageID parameter to return the status of a message (sent, queued, or error description).

GetMessageStatus Request

Parameter Name Data Type Sample Input
MessageID: Input unique Guid ID that is returned with every SMS message sent. Guid B01d89fd-5155-5455-5585-e84ab8de8591

HTTP Method

HTTP Method: GET

Url: http://sms2.cdyne.com/sms.svc/GetMessageStatus?MessageID={MESSAGEID}

Url: https://sms2.cdyne.com/sms.svc/GetMessageStatus?MessageID={MESSAGEID}

GetMessageStatus 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 an array of type SMSIncomingMessage SMSIncomingMessage[] See Table Below
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


SMSIncomingMessage Parameter Name Data Type Sample Output
FromPhoneNumber: Returns the phone number that sent this incoming message. String 17575449510
IncomingMessageID: Returns a unique Guid ID for this incoming message. Guid 1835fecd-8402-4b02-91a4-5f4f9e036fe6
MatchedMessageID: Returns a unique Guid ID that matches the outgoing MessageID that this message is in response to. Guid B01d89fd-5155-5455-5585-e84ab8de8591
Message: Returns the content of the incoming message. String Ok.
ResponseReceiveDate: Returns the UTC Date and Time of when the message was received. DateTime 0001-01-01T00:00:00
ToPhoneNumber: Returns the destination phone number of this incoming message. String 17577698337

XML Response

The following is an example response Xml body:


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

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":[{
		"FromPhoneNumber":"String content",
		"IncomingMessageID":"1627aea5-8e0a-4371-9022-9b504344e724",
		"MatchedMessageID":"1627aea5-8e0a-4371-9022-9b504344e724",
		"Message":"String content",
		"ResponseReceiveDate":"\/Date(928164000000-0400)\/",
		"ToPhoneNumber":"String content"
	}],
	"Sent":true,
	"SentDateTime":"\/Date(928164000000-0400)\/"
}

C#

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

Get Message Status

1 WSDL.IsmsClient client = new WSDL.IsmsClient("sms2wsHttpBinding");        
2 WSDL.SMSResponse resp = client.GetMessageStatus(new Guid("MESSAGE ID HERE"));
3 Console.WriteLine(resp.SentDateTime + " " + resp.SMSError );
4 Console.ReadLine();        
5 client.Close();

Send Message Then Get Message Status

 1 IsmsClient client = new IsmsClient("sms2wsHttpBinding");
 2 SMSResponse resp = client.SimpleSMSsend("17575449510", "CDYNE Test Message", new Guid("YOUR LICENSE KEY"));
 3 DateTime sentTime = DateTime.Now;
 4 TimeSpan span = DateTime.Now - sentTime;
 5 while (!sent && span.TotalSeconds < 5)
 6 {
 7 Thread.Sleep(5000);
 8 resp = client.GetMessageStatus(resp.MessageID);
 9 sent = resp.Sent;
10 span = DateTime.Now - sentTime;
11 }
12 Console.WriteLine("Message Sent: " + resp.Sent + "\n" + "Error: " + resp.SMSError + "\n" + "Message ID: " + resp.MessageID);
13 Console.ReadLine();
14 client.Close();

VB.NET

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

Get Message Status

 1 Imports GetMessageStatus.WSDL
 2 Module Module1
 3     Sub Main()
 4         Dim client As New GetMessageStatus.WSDL.IsmsClient("sms2wsHttpBinding")
 5         Dim resp As GetMessageStatus.WSDL.SMSResponse = client.GetMessageStatus(New Guid("MESSAGE ID HERE"))
 6         Console.WriteLine(resp.SentDateTime & " " & resp.SMSError)
 7         Console.ReadLine()
 8         client.Close()
 9     End Sub
10 End Module

Send Message Then Get Message Status

 1 Imports VBapp.SMS
 2 Module Module1
 3     Dim WithEvents T As System.Timers.Timer = New System.Timers.Timer(5000)
 4     Dim messageID As Guid
 5     Dim client As IsmsClient = New IsmsClient("sms2wsHttpBinding")
 6     Sub Main()
 7         Dim res As SMS.SMSResponse = client.SimpleSMSsend("7575449510", "Hi Tom", Guid.Empty)
 8         messageID = res.MessageID
 9         T.Start()
10         Console.ReadLine()
11     End Sub
12 
13     Private Sub ttick(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles T.Elapsed
14         Console.WriteLine("Tick")
15         Dim resp As SMS.SMSResponse = client.GetMessageStatus(messageID)
16         If resp.SMSIncomingMessages.Length > 0 Then
17             Console.WriteLine(resp.SMSIncomingMessages(0).Message)
18             T.Stop()
19             Console.WriteLine("Timer Close")
20         End If
21     End Sub
22 End Module

GetMessageStatus Code Examples

PHP

  • Returns the status of a single SMS message using the Message ID from the SMSResponse object.
1 $client = new SoapClient('http://sms2.cdyne.com/sms.svc?wsdl');
2 
3 $param = array(
4 		'MessageID' => '(your message ID here)'//MessageID from SMSResponse Object
5 );
6 
7 $result = $client->GetMessageStatus($param);
8 
9 print_r($result);

PHP with cURL

  • Returns the status of a single SMS message using the Message ID from the SMSResponse object.
 1 $url='http://sms2.cdyne.com/sms.svc/GetMessageStatus?MessageID=(MESSAGE ID HERE)';
 2 
 3 $cURL = curl_init();
 4  
 5 curl_setopt($cURL,CURLOPT_URL,$url);
 6 curl_setopt($cURL,CURLOPT_HTTPGET,true);
 7 curl_setopt($cURL, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Accept: application/json'));
 8 
 9 $result = curl_exec($cURL);
10  
11 curl_close($cURL);
12 
13 print_r($result);

VBScript

1 Dim oXMLHTTP
2 Set oXMLHTTP = CreateObject("Microsoft.XMLHTTP")
3 Set oDoc = CreateObject("MSXML2.DOMDocument")
4 Call oXMLHttp.Open("GET", "http://sms2.cdyne.com/sms.svc/GetMessageStatus?MessageID=MESSAGE ID HERE", False)
5 Call oXMLHttp.setRequestHeader("Content-Type", "text/xml")
6 Call oXMLHTTP.send
7 MsgBox oXMLHTTP.responseText

Ruby

1 require 'net/http'
2 require 'URI' 
3 puts URI.methods 
4 url = URI.parse('http://sms2.cdyne.com/sms.svc/GetMessageStatus?MessageID=MESSAGE ID HERE')
5 res = Net::HTTP.get_response(url) 
6 data = res.body 
7 puts data
8 gets data

JAVA

 1 import java.io.ByteArrayOutputStream;
 2 import java.io.InputStream;
 3 import java.net.MalformedURLException;
 4 import java.net.URL; 
 5 import java.util.Properties;
 6 import javax.xml.transform.OutputKeys;
 7 import javax.xml.transform.Source;
 8 import javax.xml.transform.Transformer;
 9 import javax.xml.transform.TransformerFactory;
10 import javax.xml.transform.stream.StreamResult;
11 import javax.xml.transform.stream.StreamSource;
12 
13 public final class GetMessageStatus{     
14     public static void main(String[] args) { 	
15 	
16     try{		
17     URL url = new URL("http://sms2.cdyne.com/sms.svc/GetMessageStatus?"
18                        + "MessageID=YOUR MESSAGEID");		
19     try{			
20     InputStream in = url.openStream(); 
21     StreamSource source = new StreamSource(in); 			
22     printResult(source);	
23     }catch(java.io.IOException e){			
24         e.printStackTrace();		
25     }		
26     }catch (MalformedURLException e){		
27         e.printStackTrace();	
28                 }     
29             }     
30             private static void printResult(Source source) {        
31                 try {            
32                 ByteArrayOutputStream bos = new ByteArrayOutputStream();
33                 StreamResult sr = new StreamResult(bos);
34                 Transformer trans = TransformerFactory.newInstance().newTransformer();
35                 Properties oprops = new Properties();
36                 oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
37                 trans.setOutputProperties(oprops);
38                 trans.transform(source, sr);            
39                 System.out.println("**** Response ******"); 
40                 System.out.println(bos.toString());
41                                 
42                bos.close();
43                System.out.println();        
44         } catch (Exception e) {            
45                 }    
46         }
47 }