Closed mohsenmehribusiness closed 3 years ago
Use:
$BOT_TOKEN="Your_Token";
$telegram = new Telegram($BOT_TOKEN);
$result = $telegram->getData(); $text = $result['message'] ['text']; $chat_id = $result['message']['chat']['id'];
if($text == /test){ $msg= 'Test is good'; $content = array('chat_id' => $chat_id, 'text' => $msg); $telegram->sendMessage($content); }
I'm also getting similar error
============[Date]============ [ 2021-01-19 05:49:34 UTC ] ==========[Response]========== ok: False error_code: 400 description: Bad Request: chat_id is empty =========[Sent Data]========== [ref] ref.chat_id= ref.text= Test
============[Trace]===========
I have used the following php code
$BOT_TOKEN="Your_Token";
$telegram = new Telegram($BOT_TOKEN); $result = $telegram->getData(); $text = $result['message'] ['text']; $chat_id = $result['message'] ['chat']['id']; $content = array('chat_id' => $chat_id, 'text' => 'Test'); $telegram->sendMessage($content);
Please help me to sort it out..
How the bot is configured ? Using the webhook ?
I haven't used webhook ? and i'm not getting chat id automatically by this script and it is required to enter chat id manually to send telegram notification message
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
hi when time i,m read this not worked :
$BOT_TOKEN="myTokenId"; $telegram = new Telegram($BOT_TOKEN); $chat_id = $telegram->ChatID(); $content = array('chat_id' => $chat_id, 'text' => 'test is good'); $telegram->sendMessage($content);
but when time i,m read this worked : `$BOT_TOKEN="myTokenId"; $telegram = new Telegram($BOT_TOKEN); //$chat_id = $telegram->ChatID(); $content = array('chat_id' => 112358796, 'text' => 'test is good'); $telegram->sendMessage($content);
this text error : ============[Date]============ [ 2020-10-30 03:45:28 Europe/Berlin ] ==========[Response]========== ok: False error_code: 400 description: Bad Request: chat_id is empty =========[Sent Data]========== [ref] ref.chat_id= ref.text= test is good
============[Trace]===========
0 C:\Users\RAYANGOSTAER2\Documents\bot telegram\vendor\eleirbag89\telegrambotphp\Telegram.php(3201): TelegramErrorLogger::log(Array, Array)
1 C:\Users\RAYANGOSTAER2\Documents\bot telegram\vendor\eleirbag89\telegrambotphp\Telegram.php(111): Telegram->sendAPIRequest('https://api.tel...', Array)
2 C:\Users\RAYANGOSTAER2\Documents\bot telegram\vendor\eleirbag89\telegrambotphp\Telegram.php(196): Telegram->endpoint('sendMessage', Array)
3 C:\Users\RAYANGOSTAER2\Documents\bot telegram\index.php(7): Telegram->sendMessage(Array)
4 {main}