Call us: +45 89 93 66 27

Sample code – SOAP using PHP

The following sample code shows, how send sms using PHP and SOAP interface:

<?php

class Message {
 function Message($ToPhonenumbers, $MessageText) {
 $this->ToPhonenumbers=new SoapVar($ToPhonenumbers, null, null, null, null, "api.suresms.com/soap/v1");
 $this->MessageText=new SoapVar($MessageText, null, null, null, null, "api.suresms.com/soap/v1");
 }
}

$url="http://api.suresms.com/soap/v1/service.asmx?wsdl";

$client = new SoapClient($url, array("trace" => 1)); //you only need trace if you want to se the request

$accountName="XXXX";
$password="yyyyy";
$message=new Message("+45XXXXXXXX","Test message");

$params=array('AccountName' => $accountName, 'AccountPassword' => $password, 'Message' => new SoapVar($message, SOAP_ENC_OBJECT));

$response=$client->CreateMessage($params);
//below is only for debugging purpose
var_dump($response);

echo "<br><br>Request:<br>";
var_dump(htmlentities($client->__getLastRequest()));

echo "<br><br>Response:<br>";
var_dump(htmlentities($client->__getLastResponse()));
?>


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

Code is courtesy of Erik Nielsen!

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.