title: Telegram Bot: How to get callback_data value?
body: <p>I have a simple bot in Telegram. My "/select" command displays two buttons and each button has its own value. So, if user clicks on a button I can get the text, but I can't get the callback_data value. Not sure what I am doing wrong.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>$update = json_decode(file_get_contents('php://input'));
  
  $callback_query = $update['callback_query'];
  
  if (isset($callback_query)){
      //Fetching callback
      $data = $callback_query-&gt;data;
      $message = $callback_query-&gt;message;
      $message_id = $callback_query-&gt;message-&gt;message_id;
      $chat_id = $message-&gt;chat-&gt;id;
  
      switch($data){
          case "1":
             bot('SendMessage',[
                 'chat_id' =&gt; $chat_id,
                 'text' =&gt; "1"
             ]);
             break;
  
         case "2":
             bot('SendMessage',[
                 'chat_id' =&gt; $chat_id,
                 'text' =&gt; "2"
              ]);
              break;
       }
     }else{
  
      $message = $update-&gt;message;
      $message_id = $update-&gt;message-&gt;message_id;
      $text = $message-&gt;text;
      $chat_id = $message-&gt;chat-&gt;id;
  
      //Statement beginning
  
      switch($text){
  
          case "/select":            
              $keyboard = array(
                  'keyboard' =&gt; [[['text' =&gt;  "one", 'callback_data' =&gt; "1"]],[['text' =&gt;  "two", 'callback_data' =&gt; "2"]]],
                  'resize_keyboard' =&gt; true, 
                  'one_time_keyboard' =&gt; true
              );
          $markup = json_encode($keyboard, true);            
  
          bot('SendMessage',[
              'chat_id' =&gt; $chat_id,
              'reply_markup' =&gt; $markup,
              'text' =&gt; "Choose your option"
          ]);
          break;            
  
      default:
  
          bot('SendMessage',[
              'chat_id' =&gt; $chat_id,
              'text' =&gt; "This is a test"
          ]);
  }
  
  }
  </code></pre>