PHP code example of telegga / laravel-sdk
1. Go to this page and download the library: Download telegga/laravel-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/ */
telegga / laravel-sdk example snippets
'user_model' => App\Domain\Accounts\Models\User::class,
'users_table' => 'account_users',
$message = $telegga->getMessage(messageId: $messageId);
$status = $message->status;
$telegramMessageId = $message->telegram_message_id;
$newValue = $message->raw()->new_api_field ?? null;
$bot = $telegga->addTelegramBot(
botName: 'auctiongate_notification_bot',
);
$username = $bot->bot_name;
$displayName = $bot->display_name;
$bots = $telegga->getAvailableBots();
$telegga->deleteTelegramBot(uuid: $bot->uuid);
use Illuminate\Support\Facades\Schedule;
Schedule::command('telegga:bots:sync')
->hourly()
->withoutOverlapping();
$result = $telegga->createConnection(
name: 'John',
telegramBotUuid: $bot->uuid,
email: '[email protected] ',
meta: [
'locale' => 'en',
],
groupId: $groupId,
);
$result = $telegga->createConnection(
name: 'John',
telegramBotUuid: $bot->uuid,
email: '[email protected] ',
userId: 42,
);
if (($result->link_status ?? null) === 'pending') {
$linkUrl = $result->link_url ?? null;
$expiresAt = $result->expires_at ?? null;
}
$connections = $telegga->getLocalConnections();
$connections = $telegga->getLocalConnections(userId: 42);
$result = $telegga->retryConnection(
uuid: $uuid,
meta: [
'locale' => 'en',
],
groupId: $groupId,
);
try {
$result = $telegga->createConnection(
name: 'John',
telegramBotUuid: $bot->uuid,
email: '[email protected] ',
);
} catch (\Telegga\Laravel\Exceptions\ConnectionException $exception) {
$uuid = $exception->connectionUuid;
}
$connection = $telegga->getConnection(uuid: $uuid);
$page = $telegga->getConnections(
email: '[email protected] ',
telegramBotUuid: $bot->uuid,
status: 'active',
cursor: $cursor,
);
foreach ($page->data as $connection) {
$externalId = $connection->external_id;
}
$nextCursor = $page->next_cursor;
$connection = $telegga->updateConnection(
uuid: $uuid,
data: [
'display_name' => 'John Smith',
'email' => '[email protected] ',
'status' => 'disabled',
],
);
$result = $telegga->regenerateConnectionCode(uuid: $uuid);
$telegga->unlinkConnection(uuid: $uuid);
$telegga->deleteConnection(uuid: $uuid);
$result = $telegga->sendMessage(
uuid: $connectionUuid,
type: 'text',
data: [
'text' => 'Order <b>#1234</b> has been shipped',
'parse_mode' => 'HTML',
'buttons' => [
[
[
'text' => 'Track order',
'url' => 'https://example.com/track/1234',
],
],
],
'disable_web_page_preview' => true,
'disable_notification' => true,
],
);
$result = $telegga->sendMessage(
uuid: $connectionUuid,
type: 'photo',
data: [
'media_id' => $mediaId,
'text' => 'Photo caption',
],
);
$message = $telegga->getMessage(
messageId: $messageId,
);
$page = $telegga->getMessages(
uuid: $connectionUuid,
status: 'sent',
from: new DateTimeImmutable('2026-07-01T00:00:00+03:00'),
to: new DateTimeImmutable('2026-07-30T23:59:59+03:00'),
cursor: $cursor,
);
foreach ($page->data as $message) {
$messageId = $message->message_id;
}
$nextCursor = $page->next_cursor;
$media = $telegga->uploadMedia(
contents: $uploadedFile->getContent(),
filename: $uploadedFile->getClientOriginalName(),
);
$mediaId = $media->media_id;
$metadata = $telegga->getMedia(
mediaId: $mediaId,
);
$group = $telegga->createGroup(
uuid: $connectionUuid,
name: 'VIP',
description: 'VIP customers',
);
$page = $telegga->getGroups(
uuid: $connectionUuid,
cursor: $cursor,
);
foreach ($page->data as $group) {
$groupId = $group->group_id;
}
$nextCursor = $page->next_cursor;
$group = $telegga->getGroup(groupId: $groupId);
$group = $telegga->updateGroup(
groupId: $groupId,
data: [
'name' => 'Premium',
'description' => 'Premium customers',
],
);
$telegga->deleteGroup(groupId: $groupId);
$result = $telegga->addConnectionToGroup(
uuid: $connectionUuid,
groupId: $groupId,
);
$telegga->removeConnectionFromGroup(
uuid: $connectionUuid,
groupId: $groupId,
);
$result = $telegga->addGroupMembers(
groupId: $groupId,
uuids: [$firstUuid, $secondUuid],
);
$telegga->removeGroupMember(
groupId: $groupId,
uuid: $firstUuid,
);
use Telegga\Laravel\BroadcastAudience;
$broadcast = $telegga->startBroadcast(
viaConnectionUuid: $connectionUuid,
type: 'text',
audience: BroadcastAudience::allLinkedUsers(),
data: [
'text' => 'Special offer!',
],
);
$broadcast = $telegga->startBroadcast(
viaConnectionUuid: $connectionUuid,
type: 'photo',
audience: BroadcastAudience::group(groupId: $groupId),
data: [
'media_id' => $mediaId,
'text' => 'New special offer',
],
);
$broadcast = $telegga->getBroadcast(
broadcastId: $broadcastId,
);
$result = $telegga->cancelBroadcast(
broadcastId: $broadcastId,
);
bash
php artisan migrate
bash
php artisan vendor:publish --tag=telegga-config
bash
composer migrate
bash
php artisan telegga:bots:sync
text
POST /webhooks/v1/telegram/connect-account
bash
php artisan telegga:webhook-events:clear
bash
php artisan telegga:webhook-events:clear 30