php - Telegram Inline Query - No Search Result

409

I am working on an inline bot on telegram so as to respond with some commands.

I successfully made the bot and it shows the options I pre-entered in a mySQL database previously with the below code.

if (isset($update["inline_query"])) {
    $inlineQuery = $update["inline_query"];
    $queryId = $inlineQuery["id"];
    $queryText = $inlineQuery["query"];

    $filtered = array_filter($results_empty, function($v) { return (stripos($v['title'], $queryText) !== FALSE); });

    $postData2 = array(
        "inline_query_id" => $inlineQuery["id"], 
        "results" => json_encode($filtered), 
        "cache_time" => 0
    );

if (isset($queryText) && $queryText !== "") {

  apiRequestJson("answerInlineQuery", [
    "inline_query_id" => $queryId,
    "results" => $postData2["results"]
  ]);
} 
else {
      apiRequestJson("answerInlineQuery", [
        "inline_query_id" => $queryId,
        "results" => $postData["results"]
      ]);
     }
}

Yet, when $querytext is empty (if (isset($queryText) && $queryText !== ""), aka default when no texts has been input, the options from$postData["results"] all show up.

And when I typed in some queries (if (isset($update["inline_query"]))), nothing shows up from$postData2["results"]. I confirm the$filtered from above actually works filtering thus$postData2 is valid.

Can someone help with this issue?

People are also looking for solutions to the problem: jquery - pass variable from js to php using POST

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.