Skip to main content

Send SMS with PHP

You can use the example below to send bulk, single or OTP sms from your PHP software.

function sendRequest($url, $xml) {

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, 'Content-Type: text/xml');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);

return curl_exec($ch);

$username = '';
$password = '';
$sender = 'APITEST';

$xml = <<<EOS
<text><![CDATA[Test Message]]></text>

$result = sendRequest(