PHP code example of js0nvr / textmagic

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

    

js0nvr / textmagic example snippets


$client = new TextmagicRestClient('<USERNAME>', '<APIV2_TOKEN>');
$result = ' ';
try {
    $result = $client->messages->create(
        array(
            'text' => 'Hello from TextMagic PHP',
            'phones' => implode(', ', array('99900000'))
        )
    );
}
catch (\Exception $e) {
    if ($e instanceof RestException) {
        print '[ERROR] ' . $e->getMessage() . "\n";
        foreach ($e->getErrors() as $key => $value) {
            print '[' . $key . '] ' . implode(',', $value) . "\n";
        }
    } else {
        print '[ERROR] ' . $e->getMessage() . "\n";
    }
    return;
}
echo $result['id'];

git clone git://github.com/textmagic/textmagic-rest-php.git
cd textmagic-rest-php