Simple Connectivity with Wrappers (PHP)
Wonderfully easy, our API wrappers offer you simplicity with the greatest flexibility. As with all our developer solutions, we offer expert support if you have any integration questions.
A few Simple Uses
Send
<?php //Send an SMS include_once('TMRestClient.php'); $tmClient = new TMRestClient('MyUser', 'MyPass', 'production'); $tmClient->sendSMS('Hello SMS World!', '447000000000', 'SenderName'); ?>
Check Balance
<?php //Get credits available include_once('TMRestClient.php'); $tmClient = new TMRestClient('MyUser', 'MyPass', 'production'); $creditsAvailable = $tmClient->getCredits(); ?>
Delivery Reports
<?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"; } } ?>
Some Text Marketer Account functions
Create Accounts
<?php //Create a sub-account include_once('TMRestClient.php'); $tmClient = new TMRestClient('MyUser', 'MyPass', 'production'); $tmClient->createSubAccount('My client', '447000000000'); ?>
Credit Transfers
<?php //Transfer 5000 credits to another account include_once('TMRestClient.php'); $tmClient = new TMRestClient('MyUser', 'MyPass', 'production'); $tmClient->transferCreditsToUser(5000, 'targetAPIusername', 'targetAPIpassword'); ?>
Refine and error capture
To complete your code you should add some error handing, to catch exceptions. All you need to do is put the wrapper function calls in a try-catch block as follows.
<?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"; ?>
It is up to you to decide how to handle the errors. We also recommend that you log them for debugging purposes. A list of the possible error codes is available in the full documentation below.
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.
More Information
For a fuller explanation, including all the operations available and how to handle errors please download the PDF documents



















