Send SMS with PHP:
Use the PHP code below to send SMS via Developers’ Central. Simply register for an HTTP API account, and you will automatically receive 10 FREE SMS credits to try our service.
Code Sample:
<?php
$user = "user";
$password = "password";
$api_id = "xxxxxxx";
$baseurl ="http://api.clickatell.com";
$text = urlencode("This is an example message");
$to = "00123456789";
// auth call
$url = "$baseurl/http/auth?user=$user&password=$password&api_id=$api_id";
// do auth call
$ret = file($url);
// explode our response. return string is on first line of the data returned
$sess = explode(":",$ret[0]);
if ($sess[0] == "OK") {
$sess_id = trim($sess[1]); // remove any whitespace
$url = "$baseurl/http/sendmsg?session_id=$sess_id&to=$to&text=$text";
// do sendmsg call
$ret = file($url);
$send = explode(":",$ret[0]);
if ($send[0] == "ID") {
echo "successnmessage ID: ". $send[1];
} else {
echo "send message failed";
}
} else {
echo "Authentication failure: ". $ret[0];
}
?>
Please note that some of the above code has been supplied to Clickatell by clients. As such, accuracy is not guaranteed by Clickatell.
Clickatell Connect API Forum Latest Posts
- Routing and Sender ID problemsabout 18 hours ago
- SMTP support on the americas account1 day ago
- Online SMS sender/receiver that works with Clickatell3 days ago
Start sending SMS now
SMS Gateway
Developers' Central
Reliable, scalable and customizable, Developers’ Central integrates with your systems and applications via our wide variety of APIs.
Try Developers' Central now& get 10 free test messages







