【问题标题】:PHP Telegram bot answerInlineQuery not workingPHP Telegram bot answerInlineQuery 不工作
【发布时间】:2017-05-13 03:21:21
【问题描述】:

我正在向我的机器人添加内联函数。我只使用 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 中输入什么?谢谢

【问题讨论】:

  • 你能把var_dump($queryId);的结果贴出来吗?
  • 字符串(18)“114300560489130387”
  • 这是 json {"inline_query_id":"114300560489130387","re​​sults":{"type":"article","id":"114300560489130387","title":"prov", "input_message_content":{"message_text":"ciao"}},"method":"answerInlineQuery"}
  • 这是查询 inline_query_id=114300560489130387&results%5Btype%5D=article&results%5Bid%5D=114300560489130387&results%5Btitle%5D=prov&results%5Binput_message_content%5D%5Bmessage_text

标签: php inline bots telegram


【解决方案1】:

此错误通常是因为您在用户向内联机器人键入内容后超过 7-8 秒才回答请求。尽量在 3 秒内回答

【讨论】:

  • 请扩展您的答案。 OP 如何确保他的答案在 3 秒内发送?他应该如何编辑他的代码。您现在发布的内容不值得回答,充其量只是评论。
猜你喜欢
  • 2018-06-13
  • 1970-01-01
  • 1970-01-01
  • 2022-06-22
  • 2017-07-22
  • 2016-07-15
  • 1970-01-01
  • 2021-11-26
  • 2019-08-07
相关资源
最近更新 更多