I'm new on this forum, the explanation is quite understandable. Below I have reported a simple code where I have 3 buttons online, of which: the url and switch_inline_query checked, while callback_data no. I split chosen if it is a message type or callback_query, but I still can't get into the condition where callback_query is different from Null. How can I solve this problem?
define('url',"https://api.telegram.org/bot".$botToken);
$update= file_get_contents('php://input');
$update= json_decode($update, TRUE);
$keyboardexampleinline = '[{"text":"Testo", "url":"www.google.it"},{"text":"Inline", "switch_inline_query":"Hello"}],[{"text":"Testo", "callback_data":"PrintMessage"}]';
if(isset($update['callback_query'])){
$query = $update['callback_query'];
$queryid = $query['id'];
$queryUserId = $query['from']['id'];
$querydata = $query['data'];
switch($querydata){
case "PrintMessage":
sendMessage($queryUserId, "How are you?", $keyboardexampleinline);
break;
}
}
else if (isset($update['message'] )){
$chatId= $update['message']['from']['id'];
$nome = $update['message']['from']['first_name'];
$text = $update['message']['text'];
switch($text){
case "/event":
sendMessage($chatId, "Keyboard test Inline", $keyboardexampleinline);
break;
}
}
function sendMessage($chatId, $text, $keys){
if(isset($keys)){
$keyboard = '&reply_markup={"inline_keyboard":['.$keys.'],"resize_keyboard": true,"one_time_keyboard": true, "selective": true}';
}
$url= url."sendMessage?chat_id=$chatId&aparse_mode=HTML&text=".urlencode($text).$keyboard;
file_get_contents($url);
}