Get SMS
Estimated reading: 2 minutes
747 views
Base URL
https://cellcast.com.au/api/v3/get-sms?message_id=<<message_id>>
Method: GET
Parameters
Header Parameters | Description |
---|---|
APPKEY | Please add provided APPKEY – linked to your Cellcast account. |
Content-Type | application/json |
API Parameters
Name | Example | Description |
---|---|---|
message_id | Response of Message ID | The Message ID of the sent sms message. |
Successful Responses
Code | Status | Description |
---|---|---|
200 | SUCCESS | Record founded |
Successful Responses look like
{
"meta": {
"code": 200,
"status": "SUCCESS"
},
"msg": "Record founded",
"data": [
{
"to": "+61NNNNNNNNN",
"body": "Here is sent message content",
"sent_time": "2019-06-15 14:04:46",
"message_id": "6EF87246-52D3-74FB-C319-NNNNNNN",
"status": "Delivered",
"subaccount_id": ""
}
]
}
Error Response
Status | Code | Description |
---|---|---|
AUTH_FAILED | 400 | You are not a registered user |
Error Responses look like
{
"meta": {
"code": 401,
"status": "AUTH_FAILED"
},
"msg": "APPKEY you have provided is invalid",
"data": []
}
PHP Code Example
You can call following function to get SMS details.
function getSms($message_id) {
try {
$url = 'https://cellcast.com.au/api/v3/get-sms?message_id=$message_id'; //API URL
$headers = array(
'APPKEY: <>',
'Accept: application/json',
'Content-Type: application/json',
);
$ch = curl_init(); //open connection
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
if (!$result = curl_exec($ch)) {
$response_error = json_decode(curl_error($ch));
return json_encode(array("status" => 400, "msg" => "Something went to wrong, please try again", "result" => $response_error));
}
curl_close($ch);
return json_encode(array("status" => 200, "msg" => "Successfully received", "result" => json_decode($result)));
} catch (\Exception $e) {
return json_encode(array("status" => 400, "msg" => "Something went to wrong, please try again.", "result" => array()));
}
}
Call Function
//Call function to get sms details
$response_status = getSms(<>);