QUERY_ID_INVALID - Telegram inline bot

Asked

Viewed 64 times

0

Hello

I’m creating an inline bot for Telegram, but I always come across the error QUERY_ID_INVALID. I don’t know where I’m going wrong...

$json = file_get_contents("php://input");
$dados = json_decode($json,true);
$id_query = $dados['inline_query']['id'];

 $resultados_inline[] = [
                        'type'  => 'article',
                        'id'    => "1",
                        'title' => "Test",
                        'message_text' => "test",
                    ];

  $post[] = [
    'inline_query_id' => $id_query,
    'results'   => serialize($resultados_inline),           
];

  $context_options = array(
'http' => array(
    'method' => 'POST',
    'header'=> "Content-type: application/x-www-form-urlencoded\r\n"
        . "Content-Length: " . strlen($post) . "\r\n",
    'content' => $post
    )
);

file_get_contents("https://api.telegram.org/bot" . $api_telegram . "/answerInlineQuery",NULL,$context);

The code runs well, but Telegram always returns that error. Could you help me?

Grateful

1 answer

1

I searched for this problem and got the following answer from Bot Support:

"inline queries require a fast Answer, if the Answer is delayed, you may get that error and the Answer won’t be Valid. I Suggest you to Answer Faster to them in order to make them work."

In short, my problem is that I was using debug mode and it was slow to respond and the API returned this error. I had to change my project because this response requires being extremely fast.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.