PHP code example of goodgoosegod / teletypesdk
1. Go to this page and download the library: Download goodgoosegod/teletypesdk 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/ */
goodgoosegod / teletypesdk example snippets
use Teletype\Sdk\TeletypeClient;
use Teletype\Sdk\Exceptions\TeletypeException;
$token = 'ваш_api_токен';
$client = new TeletypeClient($token);
try {
// Отправка сообщения
$response = $client->sendMessage('dialog_123', 'Привет, мир!');
echo "Сообщение отправлено! ID: " . $response['data']['messageId'];
} catch (TeletypeException $e) {
echo "Ошибка: " . $e->getMessage();
}
try {
$client->sendMessage('invalid_id', 'Текст');
} catch (Teletype\Sdk\Exceptions\TeletypeException $e) {
echo "Ошибка {$e->getCode()}: {$e->getMessage()}";
}