php - Telegram Inline Query - No Search Result
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?