GetUnsentMessages
Returns an array of unsent SMS Messages queued between the given dates
/// uses JQuery libraryvar postUrl = 'https://secure.smsgateway.ca/services/message.svc/' + accountKey + '/unsent/' + messageStatus;var body = JSON.stringify({ DateFrom: '2016-01-01', DateTo: '2016-01-07',});$.ajax({ url: postUrl, method: 'POST', contentType: 'application/json;charset=UTF-8', data: body,}) .done(function (response) { alert(response); }) .error(function (xhr, textStatus, errorThrown) { alert(xhr.responseText); });<?php// using SOAP Module - http://ca3.php.net/soap
class SMSParam { public $AccountKey; public $DateFrom; public $DateTo public $MessageStatus;}
$client = new SoapClient('https://secure.smsgateway.ca/sendsms.asmx?WSDL');$parameters = new SMSParam;
$parameters -> AccountKey = accountKey;$parameters -> DateFrom = '2016-01-01';$parameters -> DateTo = '2016-02-01';$parameters -> MessageStatus = messageStatus;
$Result = $client->GetCreditsUsedInDateRange($parameters);?>' Service Reference (SOAP)Using client = New SwiftSMS.SendSMSSoapClient Dim response = client.GetUnsentMessages(accountKey, dateFrom, dateTo, messageStatus)End Using
' WebClient (REST)Dim url = String.Format("https://secure.smsgateway.ca/services/message.svc/{0}/unsent/{1}/", accountKey, messageStatus)
Dim dateFrom = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd")Dim dateTo = DateTime.Now.ToString("yyyy-MM-dd")
Dim body = String.Format("{{ " & _ """NumberOfCredits"": {0}, " & _ """DateTo"": {1} " & _ "}}", dateFrom, dateTo)
Using wClient = New Net.WebClient wClient.Encoding = New UTF8Encoding() wClient.Headers.Add(HttpRequestHeader.ContentType, "application/json")
Dim wResponse = wClient.UploadString(url, body)End Usingcurl -X POST https://secure.smsgateway.ca/services/account.svc/[accountKey]/unsent/[messageStatus] ^ -H "Content-Type:application/json" -d @data.txt// Service Reference / SOAPusing (var client = new SwiftSecure.SendSMSSoapClient()){ var messages = client.GetUnsentMessages(accountKey, dateFrom, dateTo, messageStatus);}
// Web Client / RESTdynamic body = new ExpandoObject();
// Convert .NET date/time to javascript friendly Unix epochsbody.DateFrom = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd");body.DateTo = DateTime.Now.ToString("yyyy-MM-dd");
var url = string.Format("https://secure.smsgateway.ca/services/message.svc/{0}/unsent/{1}", accountKey, messageStatus);
using (var wClient = new System.Net.WebClient()){ wClient.Encoding = Encoding.UTF8; wClient.Headers.Add(HttpRequestHeader.ContentType, "application/json");
var messagesUsed = wClient.UploadString(url, Newtonsoft.Json.JsonConvert.SerializeObject(body));}HTTP Request
POST:
/services/message.svc/:accountKey/unsent/:messageStatus| Parameter | Description | Location |
|---|---|---|
| accountKey | Your Swift SMS Gateway account key | URL |
| messageStatus | The status of the unsent message (1 = Pending, 2 = Time Restriction, 3 = Failed) | URL |
| DateFrom | Start date of the date range to report on | BODY |
| DateTo | End date of the date range to report on | BODY |
Returns
Array of SMSOutgoingMessage