PHP code example of shamimstack / tgsdk
1. Go to this page and download the library: Download shamimstack/tgsdk 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/ */
shamimstack / tgsdk example snippets
'disks' => [
// ...
'telegram' => [
'driver' => 'telegram',
],
],
use Illuminate\Support\Facades\Storage;
// Upload a file
Storage::disk('telegram')->put('documents/report.pdf', $fileContents);
// Upload from a stream
Storage::disk('telegram')->putStream('videos/clip.mp4', fopen('/path/to/file', 'r'));
// Check if file exists
$exists = Storage::disk('telegram')->exists('documents/report.pdf');
// Get file contents (downloads from Telegram)
$contents = Storage::disk('telegram')->get('documents/report.pdf');
// Get a public/signed download URL
$url = Storage::disk('telegram')->url('documents/report.pdf');
// Get file metadata
$size = Storage::disk('telegram')->size('documents/report.pdf');
$mime = Storage::disk('telegram')->mimeType('documents/report.pdf');
// Delete a file
Storage::disk('telegram')->delete('documents/report.pdf');
use Shamimstack\Tgsdk\Events\TelegramUploadCompleted;
use Shamimstack\Tgsdk\Events\TelegramUploadFailed;
bash
php artisan vendor:publish --tag=telegram-storage-config
php artisan vendor:publish --tag=telegram-storage-migrations
php artisan migrate