SendBulkMessage
Sends an SMS message to all the cell numbers provided (maximum of 5000). Returns the number of messages successfully queued, or an error message on failure.
// uses JQuery libraryvar postUrl = "https://secure.smsgateway.ca/services/message.svc/" + accountKey + "/Bulk";var body = JSON.stringify({ MessageBody: "Message Body", Reference: "Reference Number", CellNumbers: [destinationNumber, destinationNumber, ...]});$.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 $MessageBody; public $Reference; public $CellNumbers;}
$client = new SoapClient('https://secure.smsgateway.ca/sendsms.asmx?WSDL');$parameters = new SMSParam;
$parameters -> AccountKey = accountKey;$parameters -> MessageBody = "This is a demonstration of SMSGateway.ca using PHP5.";$parameters -> Reference = reference;$parameters -> CellNumber = (destinationNumber, destinationNumber, ...);
$Result = $client->SendBulkMessage($parameters);?>Dim numbers = New ArrayOfString()numbers.Add(destinationNumber)' Service Reference (SOAP)Using client = New SwiftSMS.SendSMSSoapClient Dim response = client.SendBulkMessage(accountKey, messageBody, reference, numbers)End Using
' WebClient (REST)Dim url = String.Format("https://secure.smsgateway.ca/services/message.svc/{0}/Bulk", accountKey)Dim body = String.Format("{{ ""MessageBody"": ""{0}"", " & _ " ""Reference"" : ""{1}"", " & _ " ""CellNumbers"": [" & _ """" & destinationNumber & """, " & _ """" & destinationNumber & """, " & _ "..." & "] " & _ "}}", 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 UsingHTTP POST:curl -H "Content-Type: application/json" -X POST \ "https://secure.smsgateway.ca/services/message.svc/[accountKey]/Bulk" \ --data "{\"MessageBody\": \"[messageBody]\", \"Reference\": \"[reference]\", \"CellNumbers\": [\"destinationNumber\", ...]}"// Create an "ArrayOfString" object with the numbers to receive the SMS messagevar numbers = new SwiftSMS.ArrayOfString { destinationNumber };
// Service Reference / SOAPusing (var client = new SwiftSMS.SendSMSSoapClient()){ var response = client.SendBulkMessage(accountKey, messageBody, reference, numbers);}
// Web Client / RESTdynamic body = new ExpandoObject();body.MessageBody = messageBody;body.Reference = reference;body.CellNumbers = numbers;
var url = string.Format("https://secure.smsgateway.ca/services/message.svc/{0}/Bulk", accountKey);
using (var wClient = new System.Net.WebClient()){ wClient.Encoding = Encoding.UTF8; wClient.Headers.Add("content-type", "application/json");
var response = wClient.UploadString(url, Newtonsoft.Json.JsonConvert.SerializeObject(body));}HTTP Request
POST:
/services/message.svc/:accountKey/Bulk| Parameter | Description | Location |
|---|---|---|
| AccountKey | Your Swift SMS Gateway account key | URL |
| MessageBody | Body of the message to send | BODY |
| Reference | Internal Reference ID | BODY |
| CellNumbers | Array of cell numbers to deliver SMS messages to | BODY |
Returns
string
If successful, will return x messages queued successfully
If unsuccessful, will return an error message (See (SendMessage))