PHP code example of tm4b / tm4b-php

1. Go to this page and download the library: Download tm4b/tm4b-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tm4b / tm4b-php example snippets






lient = \Tm4b\Rest\Client::create([
    'apiKey' => 'TM4B_API_KEY'
]);




lient = \Tm4b\Rest\Client::create([
    'apiKey' => 'TM4B_API_KEY'
]);

try {
    $response = $msgClient->messages()->send([
        'destination_address' => '+441234567890',
        'source_address'      => 'master',
        'content'             => 'There is a civil war between the Galactic Empire and a Rebel Alliance.'
    ]);
    print_r($response);
} catch (\Tm4b\Exception\HttpClientException $e) {
    print_r($e->getResponseBody());
}



lient = \Tm4b\Rest\Client::create([
    'apiKey' => 'TM4B_API_KEY'
]);

$response = $msgClient->messages()->send([
    [
        'destination_address' => '+447711961111',
        'source_address'      => 'GeorgeLucas',
        'content'             => 'There is a civil war between the Galactic Empire and a Rebel Alliance.'
    ],
    [
        'destination_address' => '+97150349030',
        'source_address'      => 'GeorgeLucas',
        'content'             => 'There is a civil war between the Galactic Empire and a Rebel Alliance.'
    ]
]);



lient = \Tm4b\Rest\Client::create([
    'apiKey' => 'TM4B_API_KEY'
]);

$msgClient->setSandbox(true);
$response = $msgClient->messages()->send([
    [
        'destination_address' => '+447711961111',
        'source_address'      => 'GeorgeLucas',
        'content'             => 'There is a civil war between the Galactic Empire and a Rebel Alliance.'
    ]
]);



lient = \Tm4b\Rest\Client::create([
    'apiKey' => 'TM4B_API_KEY'
]);
$response = $msgClient->account()->describe();



lient = \Tm4b\Rest\Client::create([
    'apiKey' => 'TM4B_API_KEY'
]);

try {
    $response = $msgClient->get('/account');
    $data = $msgClient->hydrate($response, null);
    print_r($data);
} catch (\Http\Client\Exception $e) {
    print_r($e->getTraceAsString());
}