Hello friends I put inline_keyboard buttons for the robot, but these

buttons are not displayed
This is the error I receive:

[09-Jun-2023 19:09:17 UTC] PHP Fatal error: Uncaught Error: Call to undefined function sendMessageWithInlineKeyboard() in /home/mhe/public_html/Sdy/coin/buttons.php:25
Stack trace:
#0 /home/mhe/public_html/Sdy/coin/bot.php(117): sendInlineKeyboard()
#1
thrown in /home/mhe/public_html/Sdy/coin/buttons.php on line 25

And this is my code (in buttons.php)👇🏻

<?php
function sendKeyboard($keyboard, $text, $chat_id, $bot_url)
{
$keyboard = [
'keyboard' => $keyboard,
'resize_keyboard' => true,
'one_time_keyboard' => true
];
$encodedKeyboard = json_encode($keyboard);
$url = "{$bot_url}sendMessage?chat_id={$chat_id}&text=" . urlencode($text) . "&reply_markup={$encodedKeyboard}";
file_get_contents($url);
}

function sendMessage($text, $chat_id, $bot_url)
{
$url = "{$bot_url}sendMessage?chat_id={$chat_id}&text=" . urlencode($text);
file_get_contents($url);
}

function sendInlineKeyboard($inline_keyboard, $text, $chat_id, $bot_url, $edit = true)
{
if ($edit) {
editMessageReplyMarkup(json_encode(['inline_keyboard' => $inline_keyboard]), $chat_id, '', $bot_url);
} else {
sendMessageWithInlineKeyboard($inline_keyboard, $text, $chat_id, $bot_url);
}
}

function sendMessageWithInlineKeyboard($inline_keyboard, $text, $chat_id, $bot_url)
{
if (!empty($inline_keyboard)) {
foreach ($inline_keyboard as &$row) {
foreach ($row as &$button) {
if (isset($button['callback_data']) && strlen($button['callback_data']) > 64) {
trigger_error('Callback data is over 64 bytes: ' . json_encode($button));
}
}
}
}
}

How can i solve this problem?

6 ответов

12 просмотров

Maybe define the function before it is used

Know- Автор вопроса
Fabian Pastor
Maybe define the function before it is used

I used two files and put the codes related to the buttons in a file called buttons and include it in the main file. Is there any problem with this file that I just sent? Do I need to send the original file codes?

Know
I used two files and put the codes related to the ...

You need to include your files. I have no idea what php version you are using or the way you load your dependencies...

Know- Автор вопроса

You call sendMessageWithInlineKeyboard function on sendInlineKeyboard function. I think you need to move sendMessageWithInlineKeyboard above sendInlineKeyboard function.

Know- Автор вопроса
Iyah
You call sendMessageWithInlineKeyboard function on...

Thanks 🙏🏻, but my problem is not solved

Похожие вопросы

Карта сайта