I'm using PHP for the telegram bot. Reply callback is working when the callback hit the callback URL but the inline keyboard callback not working. When I click on the inline keyboard button, nothing responds, why it's happening? Please help me to fix the issues.
$update = file_get_contents('php://input');
$update = json_decode($update, true);
$userChatId = $update["message"]["chat"]["id"]?$update["message"]["chat"]["id"]:null;
if($userChatId){
$userMessage = $update["message"]["text"]?$update["message"]["text"]:"Nothing";
$firstName = $update["message"]["from"]["first_name"]?$update["message"]["from"]["first_name"]:"N/A";
$lastName = $update["message"]["from"]["last_name"]?$update["message"]["from"]["last_name"]:"N/A";
$fullName = $firstName." ".$lastName;
$callback_query = $update['callback_query'];
$callback_query_data = $callback_query['data'];
$url = "https://webhook.site/f695055e-5a65-4120-9ea2-0581667bbd61?kk=";
if(isset($callback_query)){
file_get_contents($url.$callback_query_data);
}
if($userMessage == "/start"){
$replyMsg = "Welcome to Bot";
$keyboard = [
'inline_keyboard' => [
[
['text' => 'Button 1', 'callback_data' => '1'],['text' => 'Button 2', 'callback_data' => '2']
],
[
['text' => 'Button 3', 'callback_data' => '3']
]
]
];
$encodedKeyboard = json_encode($keyboard);
$parameters = array(
"chat_id" => $userChatId,
"text" => $replyMsg,
'reply_markup' => $encodedKeyboard
);
send("sendMessage", $parameters);
}
}
function send($method, $data){
$BOT_TOKEN = "Telegram_key";
$url = "https://api.telegram.org/bot$BOT_TOKEN/$method";
if(!$curld = curl_init()){
exit;
}
curl_setopt($curld, CURLOPT_POST, true);
curl_setopt($curld, CURLOPT_POSTFIELDS, $data);
curl_setopt($curld, CURLOPT_URL, $url);
curl_setopt($curld, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($curld);
curl_close($curld);
return $output;
}
?> ```