phprestclickatell

Using Clickatell's REST api in PHP


I'm trying to programmatically send SMS messages in my php code using the REST api from Clickatell. I've got this code:

<?php
$message = "Test Message";
$numbers = array("1**********","1**********");
$data = json_encode(array("text"=>$message,"to"=>$numbers));
$authToken = "none of your buisness";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,            "https://api.clickatell.com/rest/message");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST,           1);
curl_setopt($ch, CURLOPT_POSTFIELDS,     $data);
curl_setopt($ch, CURLOPT_HTTPHEADER,     array(
    "X-Version: 1",
    "Content-Type: application/json",
    "Accept: application/json",
    "Authorization: Bearer $authToken"
));

$result = curl_exec ($ch);

echo $result
?>

It all seems to work, because this is the result I'm getting:

{
"data": {
    "message":[
        {
            "accepted":true,
            "to":"1**********",
            "apiMessageId":"e895a0e68089d76fa05f41046a186a70"
        }
    ]
}
}

However, I haven't received the message on my device. Is this something I can debug or is it beyond me?


Solution

  • The apiMessageId (tracking code) that you got back does not confirm actual delivery - it simply means the message has been accepted for processing.

    It looks like you sent a message to the USA, with an account that does not have access to the USA. You can contact the support team to assist you with setting up/getting the correct account that allows USA delivery.