You can use this request to send transactional SMSes.
Transactional SMSes allow you to send once-off SMSes to your contacts. These on-demand SMSes are generated in real-time. Transactional SMSes allow you to send a single message to a single contact at a time. For example, if you need to send a one-time pin to a contacts, you can use transactional SMS to do so.
Your method must be structured as follows:
The following parameters are required:
|message||string||The sms message to be sent.||yes||Only plain text is accepted. Do not send multimedia.|
|mobile_number||string||The mobile number the sms message must be sent to.||yes||Using mobile numbers with country code is advised.|
A successful call will return HTTP STATUS: 200, and the reason phrase will be: "Your message has been sent."
A possible processing deference will return HTTP STATUS 201.
You can treat any other HTTP STATUS as a failure.
$url = YOUR_EVERLYTIC_INSTALL_URL /api/2.0/production/sms/message';
$post = json_encode(['message' => 'Your sms message','mobile_number' => '27711231234']);
$username = 'YOUR_USER_NAME';
$apiKey = 'YOUR_API_KEY';
$cSession = curl_init();
$headers = array(
curl_setopt($cSession, CURLOPT_URL, $url);
curl_setopt($cSession, CURLOPT_USERPWD, $username . ":" . $apiKey);
curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cSession, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($cSession, CURLOPT_POSTFIELDS, $post);
curl_setopt($cSession, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($cSession);
The rest of this document describes the example above, step-by-step.
In our Getting Started section we covered the four important components of an API request; URL, method, headers, and body.
Let's analyse the code sample above to determine where each line fits into this outline.
The following line of code tells the server which API URL to access for the request:
The following code authenticates your username and API key:
cURL is a tool for sending and receiving files from a web server. This line of code initialises the cURL session.
This section of the code opens the headers section, tells the API that the REST function is a JSON object being parsed as a string.