Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 659
Pedro Antônio Avatar asked Sep 20 '26 10:09

Pedro Antônio


1 Answers

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.

like image 197
Ricardo Santos Avatar answered Sep 23 '26 22:09

Ricardo Santos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!