PHP Telegram bot answerInlineQuery无法正常工作

时间:2016-12-28 19:57:02

标签: php inline bots telegram

我正在为我的机器人添加内联功能。我只使用PHP。我写了这个,对我来说似乎很好:

$content = file_get_contents("php://input");

$update = json_decode($content, true);

$inlineQuery = isset($update["inline_query"]) ? $update["inline_query"] : "";


if ($inlineQuery["query"] !== "" ) {
    $queryId = $inlineQuery["id"];
    $collection = array(
          "type" => "article",
          "id" => $queryId,
          "title" => "prov",
          "input_message_content" =>   array( "message_text" => "ciao") ,
        );

    $parameters =  array(
    "inline_query_id" => $queryId,
    "results" => $collection,
    );

    $parameters["method"] = "answerInlineQuery";

}

echo json_encode($parameters);

我收到此错误:

{"ok":false,"error_code":400,"description":"Bad Request: QUERY_ID_INVALID"}

我需要在id中添加什么?感谢

1 个答案:

答案 0 :(得分:1)

此错误通常是因为您在用户向内联机器人输入内容后超过7-8秒回复请求。尝试回答不到3秒