1. Go to this page and download the library: Download kyle2142/phpbot 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/ */
kyle2142 / phpbot example snippets
$bot = new kyle2142\PHPBot('12345678:ABCDEF123456890abcdef'); //replace with your token
print_r($bot->api->getMe()); //dump bot info
$me = 98765432; //replace with your ID
$bot->sendMessage($me, "Hello World!");
$result = $bot->sendmessage('@mychannel', "New stuff at example.com!");
$params = ['chat_id'=>343859930, 'from_chat_id' => $result->chat->id, 'message_id' => $result->message_id];
$bot->api->forwardMessage($params); //put params as variable due to line length
php > var_dump($bot->deleteMessage(343859930, 172));
PHP Warning: Uncaught TelegramException: 400 (Bad Request: message to delete not found)
Trace:
//trace omitted
try{
$bot->deleteMessage(343859930, 172);
}catch(\kyle2142\TelegramExeption $exception){
echo "Error code was {$exception->getCode()}\n
Telegram says '{$exception->getMessage()}' ";
}
Error code was 400
Telegram says 'Bad Request: message to delete not found'
try{
$bot->editMessage(343859930, 173, "beep");
}catch(\kyle2142\TelegramFloodWait $exception){
echo "We need to wait {$exception->getRetryAfter()} seconds";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.