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";

$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.") )
{
   //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.