<?php
include_once('TMRestClient.php');
$tmClient = new TMRestClient('MyUser', 'MyPass', 'production');
try {
$success = false;
$tmClient->sendSMS('Hello SMS World!', '447000000000', 'SenderName');
// if the send fails, execution jumps to the start of the catch-block
$success = true;
$creditsAvailable = $tmClient->getCredits();
} catch (Exception $exception) {
$errors = $tmClient->getLastErrors();
foreach($errors as $errorcode => $errormsg)
echo "Code $errorcode: $errormsg";
}
if (!$success)
echo "There was a problem sending the message";
else
echo "There are $creditsAvailable credits left";
?> |