1. Go to this page and download the library: Download mitokande/php-telegram 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/ */
mitokande / php-telegram example snippets
use Mitokande\PhpTelegram\TelegramBotCreator;
use Mitokande\PhpTelegram\TelegramMessage;
TelegramBotCreator::SetTelegramBot(__Your_Token__);
TelegramBotCreator::$TelegramBot->SendTelegramMessage(new TelegramMessage(__RECEIVER_CHAT_ID__, __YOUR_MESSAGE_));
use Mitokande\PhpTelegram\TelegramBotCreator;
use Mitokande\PhpTelegram\TelegramMessage;
TelegramBotCreator::SetTelegramBot(__Your_Token__);
TelegramBotCreator::$TelegramBot->SendMultipleTelegramMessage(__ARRAY_OF_CHAT_ID_STRINGS__, __YOUR_MESSAGE__);
use Mitokande\PhpTelegram\TelegramBotCreator;
use Mitokande\PhpTelegram\TelegramMessage;
use Mitokande\PhpTelegram\TelegramMessageResult;
class TelegramMessager
{
public function __construct()
{
TelegramBotCreator::SetTelegramBot(__Your_Token__);
}
public function SendWelcomeMessage($chat_id): TelegramMessageResult
{
$bot = TelegramBotCreator::$TelegramBot;
return $bot->SendTelegramMessage(new TelegramMessage($chat_id, __WELCOME_MESSAGE_FOR_USERS__));
}
public function SendPingMessage($chat_id): TelegramMessageResult
{
return TelegramBotCreator::$TelegramBot->SendTelegramMessage(new TelegramMessage(__RECEIVER_CHAT_ID__, __YOUR_MESSAGE_));
}
public function SendMultiplePingMessage($chat_id_list): TelegramMessageResult
{
return TelegramBotCreator::$TelegramBot->SendMultipleTelegramMessage($chat_id_list, __YOUR_MESSAGE_));
}
}
use Mitokande\PhpTelegram\TelegramBot;
use Mitokande\PhpTelegram\TelegramMessage;
$bot = TelegramBot::GetInstance(__Your_Token__);
$newMessage = new TelegramMessage(__Your_ChatID__, __Your_Message__);
$result = $bot->SendTelegramMessage($newMessage);
composer
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.