skip to Main Content

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-urlencodedrn"
            . "Content-Length: " . strlen($post) . "rn",
        '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

2

Answers


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

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search