this is the library
https://github.com/TelegramBot/
I want it when I user sends a command on telegramBot conversation, then the php page of telegrambot to execute http get or post to the webserver installed on raspberry pi it has public ip with dns name and it is reachable from public internet.
I tried this PHP code which is telegrambot callback webhook (https://server.com/bot.php)
Code: Select all
<?php
require_once "vendor/autoload.php";
try {
/// XXXXXXX is the token
$bot = new \TelegramBot\Api\Client('XXXXXXX');
$bot->command('test', function ($message) use ($bot) {
file_get_contents("http://1.2.3.4:11258/get.php");
$bot->sendMessage($message->getChat()->getId(), 'received');
});
$bot->run();
} catch (\TelegramBot\Api\Exception $e) {
$e->getMessage();
}
?>
apache installed on raspberry pi is listening on port 11258
http://1.2.3.4:11258
am I doing something wrong?
if there are any different approaches please let me know.