Please, How can I fix this error in PHP? Bad Request:

can't parse inline keyboard button: Field "text" must be of type String

Please @SpEcHIDe, Help me

12 ответов

47 просмотров

Field "text" must be of type String in inline buttons

I think incorrect request, can you check your reply markup ? 🤔

𓂆 معاذ-القَرْني Автор вопроса

See, I have method called GetButtons this code: $buttons = []; $i = 0; foreach ($this->Questions as $question) { array_push($buttons, [['text' => $question, 'callback_data' => "answer_$i"]]); $i++; } And this is the request $this->Bot->SendMessage([ 'chat_id' => $message->chat->id, 'text' => 'These are FAQ Questions, Choose one from these questions to get answer', 'reply_markup' => ['inline_keyboard' => $this->GetButtonsByPageID(0)] ]);

$question is not a string

𓂆 معاذ-القَرْني Автор вопроса

This is questions: [ 'How are you' => 'I am good', 'What's your name' => 'blabla' ]

foreach ($this->Questions as $question) { array_push($buttons, ['text' => $question, 'callback_data' => "answer_$i"]); $i++; } Can you try ?

𓂆 معاذ-القَرْني Автор вопроса

This error: Array to string conversion

GetButtonsByPageID(0) is not returning a string.

𓂆 معاذ-القَرْني Автор вопроса

Should it return string?

I am not sure of the usage of the for loop, with multi dimensionnal arrays 🙊😅😅

sorry, I misread the code. anyways, you need to look at the raw output of your code. the text field is either not being filled in, or is being filled in with something that isn't a string

𓂆 معاذ-القَرْني Автор вопроса

Para

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

Карта сайта