Api icon indicating copy to clipboard operation
Api copied to clipboard

answerInlineQuery not working?

Open maksutovnurda opened this issue 4 years ago • 1 comments

$bot->inlineQuery(function($update) use ($bot){
    $content = new \TelegramBot\Api\Types\Inline\InputMessageContent\Text('*Test*', 'html');
    $result = new \TelegramBot\Api\Types\Inline\QueryResult\Article(time(),'Title', null,null,null,null, $content);
    $bot->answerInlineQuery($update->getId(), $result);

    $bot->sendMessage(808542421, $update->getid().$update->getQuery()); //FOR TESTING
});

No matter how much I test, no error, no result. sendMessage send inline query id, and query the itself. But $bot->answerInlineQuery don't do anything. Also code in bottom works good.

$inlineResult = [
  [
    "type" => "article",
    "id" => time(), 
    "title" => "Title",
    "input_message_content" => [
      "message_text" => "*Test*",
      "parse_mode" => "Markdown",
  ],
] ];
$uqid =  $update->getid();
file_get_contents("https://api.telegram.org/bottoken/answerInlineQuery?inline_query_id$uqid&results=".json_encode($inlineResult));

maksutovnurda avatar Jan 13 '22 22:01 maksutovnurda

@maksutovnurda You should pass an array of results, see https://core.telegram.org/bots/api#answerinlinequery This will work:

$bot->answerInlineQuery($update->getId(), [$result]);

Cherry-Pie avatar Apr 11 '22 08:04 Cherry-Pie