Call us: +45 89 93 66 27

Sample code – HTTP(s) – PHP

You can tell our SMS server, that you want to send a text message by making a HTTP request to our SMS script.

The following Sample code shows, how to make an integration in PHP with HTTPs:

$message = "Your message";

//utf8_encode() - makes it possible to send æ,ø,å and other special chars
$curlUrl = "https://api.suresms.com/script/sendsms.aspx?login=USER&password=PASSWORD&to=+". $phone ."&from=SENDER&message=". urlencode ( $message );

ob_start();
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl, CURLOPT_URL, $curlUrl);
$result = curl_exec ($curl);

$hs = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$header = substr($result, 0, $hs);
$body = substr($result, $hs);

curl_close ($curl);
ob_end_clean();

if(0 == strcmp(substr($header, 0, 13), "Message sent.") || 0 == strcmp(substr($header, 0, 39), "The same message to the same recipient"))
{
   //The sms was sent
}
else
{
   //The sms was NOT sent
}

It is nessasary to change the parametres, so that they do match the username and Password, you recieved when opening your SureSMS account!

Should you have any questions, you are allways welcome to send an E-mail to support@suresms.com. We are looking forward to helping you.

Need an account?

Do you still need an account or a free test account? Follow this link and we will make you one in 5 minuts.