Pedro Antônio
Pedro Antônio

Reputation: 405

QUERY_ID_INVALID - Telegram inline bot

I have a problem with inline bots with Telegram API...

I have the code:

$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);

But i receive:

{"ok":false,"error_code":400,"description":"BadRequest:QUERY_ID_INVALID"}

Can somebody help me?

Thanks

Upvotes: 3

Views: 1805

Answers (2)

Ricardo Santos
Ricardo Santos

Reputation: 194

I searched for this problem and i got this 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."

i just stop to use debugger mode and all works, this is a API restriction to UX.

Upvotes: 7

ihoru
ihoru

Reputation: 1980

This error is possible if inline query timeouted. If you send fresh request everything will be Ok.

Upvotes: 1

Related Questions