1. Go to this page and download the library: Download usmonaliyev/telegrambotphp 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/ */
usmonaliyev / telegrambotphp example snippets
$telegram = new Telegram('YOUR TELEGRAM TOKEN HERE');
// Load a local file to upload. If is already on Telegram's Servers just pass the resource id
$img = curl_file_create('test.png','image/png');
$content = array('chat_id' => $chat_id, 'photo' => $img );
$telegram->sendPhoto($content);
$telegram = new Telegram('YOUR TELEGRAM TOKEN HERE');
$req = $telegram->getUpdates();
for ($i = 0; $i < $telegram-> UpdateCount(); $i++) {
// You NEED to call serveUpdate before accessing the values of message in Telegram Class
$telegram->serveUpdate($i);
$text = $telegram->Text();
$chat_id = $telegram->ChatID();
if ($text == '/start') {
$reply = 'Working';
$content = array('chat_id' => $chat_id, 'text' => $reply);
$telegram->sendMessage($content);
}
// DO OTHER STUFF
}