Sending SMS

There are two methods that can be used to send SMS. Use message_send() for transactional one at a time messages and batch_create() for sending out bulk SMS campaigns to CSV files.

Important information

Hostname: smsapi.totalsend.com
HTTP port 80
Type of request: GET

message_send()

This  method is for sending a single transactional message. Examples of this  could be sending a verification code to a user via SMS or another  similar type of notification.

Arguments

Argument
Type
Description
username
string
Your TotalSend username
password
string
Your TotalSend password
to
string
The mobile number that must receive the SMS
text
string
Content of the message
from
string
The from number of the message (source address)
report_mask
int
Delivery report request bitmask (see delivery_report_mask_* variables)
report_url
string
URL to call when delivery status changes. More info.
charset
string
Character set to use (defaults to UTF-8)
data_coding
int
Data coding (see data_coding_*)
message_class
int
Optional.  Sets the Message Class in DCS field. Accepts values between 0 and 3,  for Message Class 0 to 3, A value of 0 sends the message directly to  display, 1 sends to mobile, 2 to SIM and 3 to SIM toolkit.
auto_detect_encoding
int
Auto  detect the encoding and send appropriately (useful for sending arabic,  hindi, unicode etc messages) 1 = on, 0 = off, defaults off.

Example

http://smsapi.totalsend.com/json/3?action=message_send&username=USERNAME&password=XX1234xx&from=SENDERID&text=Hello+world&to=278312345678

Result

In the return result, if successful the details key will contain the message ID.

{"status":1,"message":"Sent","description":"","details":"20ee797d-b62e-4632-0106-090500000006"}



batch_create()

This method is for sending bulk SMS campaigns to .CSV, .TXT, .XLS, .XLSX and any other comma delimited file.

Arguments

Argument
Type
Description
username
string
Your TotalSend username
password
string
Your TotalSend password
name
string
A description / name for this batch
throughput
int
Throughput to deliver this batch at (per second)
file_type
string
File type of the upload ( csv, xls or zip accepted )
start_time
string
If the batch must be auto-started at a given time, it must be specified here: eg: 2012-03-04 08:00:00

Including your batch file

Due  to the limits of GET parameters, using the batch_create() method  requires the batch file to be uploaded as a POST variable. The POST  variable that must be used is named ‘data’. If the file is compressed  using ZIP compression the POST data will need to be base 64 encoded  prior to upload.

Pseudo code:

batchCsvData = readFile(myBatchFile.csv); if(batchFileIsZip) {  batchCsvData = Base64Encode(batchCsvData); }
postData = “data=“ + batchCsvData;

Result

If the batch is successfully created a batch ID will be returned.