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.

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

ArgumentTypeDescription
usernamestringYour TotalSend username
passwordstringYour TotalSend password
tostringThe mobile number that must receive the SMS
textstringContent of the message
fromstringThe from number of the message (source address)
report_maskintDelivery report request bitmask (see delivery_report_mask_* variables)
report_urlstringURL to call when delivery status changes. More info.
charsetstringCharacter set to use (defaults to UTF-8)
data_codingintData coding (see data_coding_*)
message_classintOptional. 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_encodingintAuto detect the encoding and send appropriately (useful for sending arabic, hindi, unicode etc messages) 1 = on, 0 = off, defaults off.

Result

In the return result, if successful the details key will contain the message ID.
Example output : {“status”:1,”message”:”Sent”,”details”:”8beda1a8-5c12-489f-0107-123000000003″}


batch_create()

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

Arguments

ArgumentTypeDescription
usernamestringYour TotalSend username
passwordstringYour TotalSend password
namestringA description / name for this batch
throughputintThroughput to deliver this batch at (per second)
file_typestringFile type of the upload ( csv, xls or zip accepted )
start_timestringIf 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.