1. Go to this page and download the library: Download prihod/terasms-client 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/ */
prihod / terasms-client example snippets
use TeraSMS\Client;
'2LsWvGkYYOjyPw3GWbp5L';
$client = new Client($login,$token );
use TeraSMS\Exception\RequestException;
use TeraSMS\Request\BalanceRequest;
try {
$request = new BalanceRequest();
$response = $client->execute($request);
if ($response->isSuccess()) {
echo "Response to array:\n";
print_r($response->toArray());
echo "Response get data:\n";
print_r($response->getData());
} else {
echo "Response Status: {$response->getStatus()}";
echo "Response Error: {$response->getError()}";
}
} catch (RequestException $e) {
echo "Exception: {$e->getMessage()}\n";
print_r($e->request->toArray());
}
use TeraSMS\Client;
use TeraSMS\Exception\RequestException;
use TeraSMS\Request\SMSRequest;
try {
$request = (new SMSRequest())
->setPhone('71234567890')
->setSender('SMSTest')
->setMessage('Message text to be sent via SMS');
$response = $client->execute($request);
if ($response->isSuccess()) {
echo "Response to array:\n";
print_r($response->toArray());
echo "Response get data:\n";
print_r($response->getData());
echo "Response get all entries:\n";
print_r($response->getEntries());
echo "Response get first entry:\n";
$entry = $response->getFirstEntry();
if ($entry->isSuccess()) {
echo "Entry to array:\n";
print_r($entry->toArray());
echo "Entry get data:\n";
print_r($entry->getData());
} else {
echo "Entry Status: {$entry->getStatus()}";
echo "Entry Error: {$entry->getError()}";
}
} else {
echo "Response Status: {$response->getStatus()}";
echo "Response Error: {$response->getError()}";
}
} catch (RequestException $e) {
echo "Exception: {$e->getMessage()}\n";
print_r($e->request->toArray());
}
use TeraSMS\Request\MultiSMSRequest;
use TeraSMS\Request\SMSRequest;
$request1 = (new SMSRequest())
->setId(1232)
->setPhone('71234567890')
->setSender('SMSTest')
->setMessage('Message text to be sent via SMS1');
$request2 = (new SMSRequest())
->setId(1233)
->setPhone('71234567891')
->setSender('SMSTest')
->setMessage('Message text to be sent via SMS2');
$multiRequest = (new MultiSMSRequest())
->append($request1)
->append($request2);
$response = $client->execute($requests);
...
use TeraSMS\Request\StatusRequest;
$request = new StatusRequest([12323, 23262, 23264]);
/**
$request = (new StatusRequest())
->setMessageIds([12323, 23262, 23264]);
$request = (new StatusRequest())
->appendMessageId(12323)
->appendMessageId(23262)
->appendMessageId(23264);
$request = (new StatusRequest())
->setMessageIds([12323, 23262, 23264]);
*/
$response = $client->execute($request);
...
use TeraSMS\Request\ViberRequest;
$request = (new ViberRequest())
->setPhone('71234567890')
->setSender('ViberTest')
->setMessage('Message text to be sent via Viber')
->setImage('https://terasms.ru/logo.jpg')
->setLink('https://terasms.ru/')
->setButtonText('Text');
$response = $client->execute($request);
...
use TeraSMS\Request\MultiViberRequest;
use TeraSMS\Request\ViberRequest;
$request1 = (new ViberRequest())
->setPhone('71234567890')
->setSender('ViberTest')
->setMessage('Message text to be sent via Viber')
->setImage('https://terasms.ru/logo.jpg')
->setLink('https://terasms.ru/')
->setButtonText('Text');
$request2 = (new ViberRequest())
->setPhone('71234567891')
->setSender('ViberTest')
->setMessage('Message text to be sent via Viber')
->setImage('https://terasms.ru/logo.jpg')
->setLink('https://terasms.ru/')
->setButtonText('Text');
$multiRequest = (new MultiViberRequest())
->append($request1)
->append($request2);
$response = $client->execute($request);
...
use TeraSMS\Request\VkRequest;
$request = (new VkRequest())
->setPhone('71234567890')
->setSender('VkTest')
->setMessage('Message text to be sent via Vk');
$response = $client->execute($request);
...
use TeraSMS\Request\WhatsAppRequest;
$request = (new WhatsAppRequest())
->setPhone('71234567890')
->setSender('WhatsAppTest')
->setMessage('Message text to be sent via WhatsApp');
$response = $client->execute($request);
...
use TeraSMS\Request\CascadeRequest;
$request = (new CascadeRequest())
->setPhone('71234567890')
->setSender('CascadeTest')
->setMessage('Message text to be sent via Cascade');
$response = $client->execute($request);
...
use TeraSMS\Request\VoiceOTPRequest;
$request = (new VoiceOTPRequest())
->setCode(2345)
->setPhone('71234567890')
->setSender('VoiceOTPTest');
$response = $client->execute($request);
...
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.