PHP code example of toucantext / php-sdk

1. Go to this page and download the library: Download toucantext/php-sdk 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/ */

    

toucantext / php-sdk example snippets


$config = [
  'username' => '{your_api_username}',
  'password' => '{your_api_password}'
];

$toucan = new ToucanText\Client($config);

// return all your messages
$toucan->messages->all();

// return 15 messages maximum and acknowledge them
$toucan->messages->all(true, 15);

// return only inbound messages
$toucan->messages->get('messagesOnly');

// return only delivery receipts
$toucan->messages->get('dlrsOnly');

// return 15 inbound messages maximum and acknowledge them
$toucan->messages->get('messagesOnly', true, 15);

// return 15 delivery receipts maximum and acknowledge them
$toucan->messages->get('dlrsOnly', true, 15);

// send a message
$message = [
  'destinationAddress' => '{the_destination_address}',
  'message => '{your_message}'
];

$toucan->messages->send($message);

// send a message with source address and request delivery receipt
$message = [
  'sourceAddress' => '{your_source_address}',
  'destinationAddress' => '{the_destination_address}',
  'message' => '{your_message}',
  'deliveryReceipt' => true
];

$toucan->messages->send($message);

// array of message ID's to acknowledge
$messages = [
    245, 4564, 456
];

$toucan->messages->acknowledge($messages);

try {
  $toucan->messages->all();
} catch (Exception $e) {
  // do something with $e
}
bash
composer requiure toucantext/php-sdk