1. Go to this page and download the library: Download vjik/telegram-bot-api 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/ */
vjik / telegram-bot-api example snippets
use Vjik\TelegramBot\Api\TelegramBotApi;
// API
$api = new TelegramBotApi(
// Telegram bot authentication token
'110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw',
);
use Vjik\TelegramBot\Api\Type\InputFile
// Specify a URL for outgoing webhook
$api->setWebhook('https://example.com/webhook');
// Send text message
$api->sendMessage(
chatId: 22351,
text: 'Hello, world!',
);
// Send local photo
$api->sendPhoto(
chatId: 22351,
photo: InputFile::fromLocalFile('/path/to/photo.jpg'),
);
// Result is an array of `Vjik\TelegramBot\Api\Update\Update` objects
$updates = $api->getUpdates();
/**
* @var \Vjik\TelegramBot\Api\TelegramBotApi $api
*/
/**
* By `File` instance
* @var \Vjik\TelegramBot\Api\Type\File $file
*/
$url = $api->makeFileUrl($file);
/**
* By file path is taken from the Telegram response
* @var string $filePath
*/
$url = $api->makeFileUrl($filePath)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.