A brief overview of the API and its purpose Endpoints: A list of all the endpoints available in the API, including their URLs and the HTTP methods they support.
Request and Response: The expected request format and the format of the response, including examples of how to use the API and the data that it returns.
Send SMS
This PHP method uses cURL to send SMS data to an API endpoint, receiving a JSON response with email request status and logs.
$curl = curl_init();
$postdata = array(
"wallet_type" => "2",
"sender_id" => "xxxxxx",
"contact" => array(
array(
"number" => "11254352345",
"body" => "In publishing and graphic design, Lorem ipsum is a",
"sms_type" => "plain"
),
array(
"number" => "32234213423",
"body" => "In publishing and graphic design, Lorem ipsum is a",
"sms_type" => "unicode"
)
)
);
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sendar.io/api/sms/send',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>json_encode($postdata),
CURLOPT_HTTPHEADER => array(
'Api-key: ###########################,
'Content-Type: application/json',
),
));
$response = curl_exec($curl);
curl_close($curl);
//response will return data in this format
{
"status": "success",
"sms_logs": [
{
"uid": "5eb8c1b2-6832-4c91-a813-6e06062c8584",
"number": "11254352345",
"status": "Pending",
"created_at": "2023-10-16 04:59 PM"
},
{
"uid": "3d783e68-8f87-4374-a6b4-d07d23b30fff",
"number": "32234213423",
"status": "Pending",
"created_at": "2023-10-16 04:59 PM"
}
],
"message": "New SMS request sent, please see in the SMS history for final status"
}
GET SMS
This PHP code, employing cURL, retrieves SMS log data for a unique identifier (uid) from an API, including status, recipient number, message content, and the last update timestamp.
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sendar.io/api/get/sms/{uid}',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Api-key: ###########################,
),
));
$response = curl_exec($curl);
curl_close($curl);
//response will return data in this format
{
"status": "success",
"sms_logs": {
"uid": "43339822-9d44-413e-b8b6-5cafc8be",
"number": "11254352345",
"content": "In publishing and graphic design, Lorem ipsum is a",
"status": "Schedule",
"updated_at": "2023-10-16 08:10 PM"
}
}