Using the SMS API with Java

Sample Code

If you cut and paste the following code into a web page and access it with a web browser, then a text message will be sent. Note that you should replace "<username>", "<password>" and "<mobile number>" with appropriate values.

Alternatively, here is a ZIP version of this code.

<html>
<body>
<?php
function sendTextMessage ($username, $password, $message, $destination) {

$host="https://www.totext.net/";
$path="selfcare/com/zipzaptext/selfcare/";
$action="SendMessagesApi.action";

$url = $host.$path.$action;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, 1);

$vars = array();
$vars["destination"]= $destination;
$vars["username"]= $username;
$vars["password"]= $password;
$vars["message"] = $message;

curl_setopt ($ch, CURLOPT_POSTFIELDS, $vars);
curl_exec ($ch);
curl_close ($ch);
}
?>

Test results:<br>
<?php
sendTextMessage ("<username>", "<password>", "Test from PHP", "<mobile number>");
?>

</body>
</html>

Having Problems?

We're very keen that your integration should be straightforward and easy, so if you're having any trouble at all, then please don't hesitate to get in touch.