GetUnreadIncomingMessages

From CDYNE Wiki
Jump to navigation Jump to search

This method returns all unread text message responses attached to a single License Key and marks them as read.

GetUnreadIncomingMessages Request

Parameter Name Data Type Sample Input
LicenseKey: Required to authenticate users invoking this Web Service.

Trial Key. Production Key.

String F01d89fd-5155-5455-5585-e84ab8de8591

HTTP Method

HTTP Method: GET

Url: http://sms2.cdyne.com/sms.svc/GetUnreadIncomingMessages?LicenseKey={LICENSEKEY}

Url: https://sms2.cdyne.com/sms.svc/GetUnreadIncomingMessages?LicenseKey={LICENSEKEY}

GetUnreadIncomingMessages Response

Parameter Name Data Type Sample Output
FromPhoneNumber: Returns the phone number that sent the incoming message. String 15551235678
IncomingMessageID: Returns a unique ID that is assigned to every incoming message received.

This is different than original MessageID.

Guid A01d89fd-5155-5455-5585-e84ab8de8591
MatchedMessageID: Returns the unique ID that was assigned to the original SMS message sent. Guid B01d89fd-5155-5455-5585-e84ab8de8591
Message: Returns a string of the incoming message sent. String Hi, Thanks for the message.
ResponseReceivedDate: Returns the date and time of when the response was received. Datetime 2010-05-11T19:17:28
ToPhoneNumber: Returns the phone number used to send the original SMS message sent. String 15551233325

XML Response

The following is an example response Xml body:


<ArrayOfSMSIncomingMessage xmlns="http://sms2.cdyne.com">
  <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>
</ArrayOfSMSIncomingMessage>

Json Response

The following is an example response Json body:


[{
	"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"
}]

GetUnreadIncomingMessages Code Examples

C#

1 IsmsClient client = new IsmsClient("sms2wsHttpBinding");
2 Array IncomingList = client.GetUnreadIncomingMessages(new Guid("YOUR LICENSE KEY"));
3 if (IncomingList.Length > 0)
4 {
5 foreach (WSDL.SMSIncomingMessage Message in IncomingList)
6 Console.WriteLine(Message.IncomingMessageID + " " + Message.FromPhoneNumber + " " + Message.Message + " " + Message.ResponseReceiveDate.ToString());
7 }
8 Console.ReadLine();
9 client.Close();

VB.NET

 1 Imports GetUnreadIncomingMessages.WSDL
 2 Module Module1
 3  Sub Main()
 4  Dim client As New GetUnreadIncomingMessages.WSDL.IsmsClient("sms2wsHttpBinding")
 5  Dim resp As GetUnreadIncomingMessages.WSDL.SMSIncomingMessage() = client.GetUnreadIncomingMessages(New Guid("YOUR LICENSE KEY"))
 6  For Each item In resp
 7  Console.WriteLine(Convert.ToString(item.FromPhoneNumber) & " " & Convert.ToString(item.Message) & " " & Convert.ToStrin(item.IncomingMessageID) & " " & Convert.ToString(item.ResponseReceiveDate))
 8  Next
 9  Console.ReadLine()
10  client.Close()
11  End Sub
12 End Module

PHP

 1 $client = new SoapClient('http://sms2.cdyne.com/sms.svc?wsdl');
 2 
 3 $param = array('LicenseKey' => '(your license key)');
 4 
 5 $result = $client->GetUnreadIncomingMessages($param);
 6 
 7 print_r($result);
 8 
 9 </codehighlight>
10 
11 === PHP with cURL ===
12 
13 <syntaxhighlight lang=php line=line>
14 
15 $url='http://sms2.cdyne.com/sms.svc/GetUnreadIncomingMessages?LicenseKey=(License Key)';
16 
17 $cURL = curl_init();
18 
19 curl_setopt($cURL,CURLOPT_URL,$url);
20 curl_setopt($cURL,CURLOPT_HTTPGET,true);
21 curl_setopt($cURL, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Accept: application/json'));
22 
23 $result = curl_exec($cURL);
24 
25 curl_close($cURL);
26 
27 print_r($result);

VBScript

1 Dim oXMLHTTP
2 Set oXMLHTTP = CreateObject("Microsoft.XMLHTTP")
3 Set oXMLHttp = CreateObject("Microsoft.XMLHTTP")
4 Set oDoc = CreateObject("MSXML2.DOMDocument") 
5 Call oXMLHttp.Open("GET", "http://sms2.cdyne.com/sms.svc/GetUnreadIncomingMessages?LicenseKey=YOUR LICENSE KEY", False)
6 Call oXMLHttp.setRequestHeader("Content-Type", "text/xml")
7 Call oXMLHTTP.send 
8 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/GetUnreadIncomingMessages?LicenseKey=YOUR LICENSE KEY')
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 GetUnreadIncomingMessages{     
14     public static void main(String[] args) { 	
15 
16             try{		
17                     URL url = new URL("http://sms2.cdyne.com/sms.svc/GetUnreadIncomingMessages?"
18                                        + "LicenseKey=YOUR LICENSE KEY");		
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 
35                     Transformer trans = TransformerFactory.newInstance().newTransformer();
36                     Properties oprops = new Properties();
37                     oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
38                     trans.setOutputProperties(oprops);
39                     trans.transform(source, sr);            
40                     System.out.println("**** Response ******"); 
41                     System.out.println(bos.toString());
42 
43                     bos.close();
44                     System.out.println();        
45             } catch (Exception e) {            
46                     }    
47             }
48     }