TelegramBot / Api

Native PHP Wrapper for Telegram BOT API
MIT License
1.06k stars 324 forks source link

Error : Call to a member function toJson() on array at BotApi.php:1342 #421

Closed sy29 closed 1 year ago

sy29 commented 1 year ago

Error : Call to a member function toJson() on array at BotApi.php:1342

    $query = $inlineQuery->getQuery();

            if ($query == 'dog') {
                $results[] = [
                    [
                        'type' => 'photo',
                        'id' => '1',
                        'photo_url' => 'https://cdn.pixabay.com/photo/2016/02/19/15/46/dog-1210559_960_720.jpg',
                        'thumb_url' => 'https://cdn.pixabay.com/photo/2016/02/19/15/46/dog-1210559_960_720.jpg',
                        'caption' => 'Adorable dog'
                    ]
                ];
            } else {
                $results[] = [
                    [
                        'type' => 'article',
                        'id' => '1',
                        'title' => 'No results found',
                        'input_message_content' => [
                            'message_text' => 'Sorry, we could not find any results for your query'
                        ]
                    ]
                ];
            }

    $bot->answerInlineQuery($id, $results);

Please help