SendMessage
Sends an SMS message to the given phone number. Returns Message queued successfully on success, or an error message on fail.
// uses JQuery libraryvar postUrl = 'https://secure.smsgateway.ca/services/message.svc/' + accountKey + '/' + destinationNumber;var body = JSON.stringify({ MessageBody: 'Message Body',});$.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 $CellNumber; public $AccountKey; public $MessageBody;}
$client = new SoapClient('https://secure.smsgateway.ca/sendsms.asmx?WSDL');$parameters = new SMSParam;
$parameters -> CellNumber = destinationNumber;$parameters -> AccountKey = accountKey;$parameters -> MessageBody = "This is a demonstration of SMSGateway.ca using PHP5.";
$Result = $client->SendMessage($parameters);?>'Using Service Reference (SOAP)Using client = New SwiftSMS.SendSMSSoapClient Dim response = client.SendMessage(destinationNumber, messageBody, accountKey)End Using
'Using Webclient (REST)Dim url = String.Format("https://secure.smsgateway.ca/services/message.svc/{0}/{1}", accountKey, destinationNumber)Dim body = String.Format("{{ ""MessageBody"": ""{0}"", ""Reference"" : ""{1}"" }}", messageBody, reference)
Using wClient = New Net.WebClient wClient.Encoding = New UTF8Encoding() wClient.Headers.Add("content-type", "application/json")
Dim wResponse = wClient.UploadString(url, body)End UsingSimple HTTP GET:curl "https://secure.smsgateway.ca/SendSMS.aspx?CellNumber=[destinationNumber]&AccountKey=[accountKey]&MessageBody=[messageBody]"
HTTP POST:curl -H "Content-Type: application/json" -X POST \ "https://secure.smsgateway.ca/services/message.svc/[accountKey]/[destination]" \ --data "{ \"MessageBody\": \"[messageBody]\" }"// Service Reference / SOAPusing (var client = new SwiftSMS.SendSMSSoapClient()){ string response = client.SendMessage(destinationNumber, messageBody, accountKey);}
// Web Client / RESTdynamic body = new ExpandoObject();body.MessageBody = "Message Body";
var url = string.Format("https://secure.smsgateway.ca/services/message.svc/{0}/{1}", accountKey, destinationNumber);
using (var wClient = new System.Net.WebClient()){ wClient.Encoding = Encoding.UTF8; wClient.Headers.Add("content-type", "application/json");
string response = wClient.UploadString(url, Newtonsoft.Json.JsonConvert.SerializeObject(body));
}HTTP Request
POST:
https://secure.smsgateway.ca/services/message.svc/:accountKey/:destinationNumberGET:
/SendSMS.aspx?CellNumber=[destinationNumber]&AccountKey=[accountKey]&MessageBody=[messageBody]| Parameter | Description | Location |
|---|---|---|
| AccountKey | Your Swift SMS Gateway account key | URL |
| DestinationNumber | Cell number to receive the text message | URL |
| MessageBody | Body of the message to send | BODY |
Returns
string
| Message | Description |
|---|---|
| Message queued successfully | Your message has been queued and will be sent. |
| Cell number is invalid | The cell number was not supplied or was too short. |
| The account key parameter was not valid | The account key was not supplied or or was less than 9 characters. |
| This account is disabled | The specified account has been disabled by our administrator for violating one or more of our policies. |
| Account key not found | The specified account key cannot be found. Please verify the key and try again. |
| There are no messages remaining on this account | You will need to purchase additional messages. |
| No authorized credit plan found to match this phone number. Please check the number, and ensure you are authorized to send messages to this region | By default, accounts are authorized to send to certain countries only. Please contact us to find out how to send to other regions. |
| Credit rule not found | You attempted to send a message to a region you do not have permission to. Please contact your account manager to check regions. - Message will not be sent |
| Message content is not acceptable, message not sent | Please contact us for details |
| Time of day at destination falls outside the established time restrictions for your account, message not sent. | For Enterprise level accounts only - optional time-of-day windows can be created to restrict sending. |