<?php
//Send an SMS
include_once('TMRestClient.php');
$tmClient = new TMRestClient('MyUser', 'MyPass', 'production');
$tmClient->sendSMS('Hello SMS World!', '447000000000', 'SenderName');
?>
<?php
//Get credits available
include_once('TMRestClient.php');
$tmClient = new TMRestClient('MyUser', 'MyPass', 'production');
$creditsAvailable = $tmClient->getCredits();
?>
<?php
//Get a delivery report of all messages sent
include_once('TMRestClient.php');
$tmClient = new TMRestClient('MyUser', 'MyPass', 'production');
$result = $tmClient->getDeliveryReport('all');
foreach ($result as $key => $report) {
	foreach ($report['reportrow'] as $key => $reportrow) {
		echo "Msg ID: {$reportrow['message_id']}, to: {$reportrow['mobile_number']}, is: {$reportrow['status']}<br/>\n";
	}
}
?>
<?php
//Create a sub-account
include_once('TMRestClient.php');
$tmClient = new TMRestClient('MyUser', 'MyPass', 'production');
$tmClient->createSubAccount('My client', '447000000000');
?>
<?php
//Transfer 5000 credits to another account
include_once('TMRestClient.php');
$tmClient = new TMRestClient('MyUser', 'MyPass', 'production');
$tmClient->transferCreditsToUser(5000, 'targetAPIusername', 'targetAPIpassword');
?>
<?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";
?>

Our example code is an illustration of how you might integrate with our systems and is not certified for production environments. You are responsible for testing and QA.