简体   繁体   中英

How to pass parameter to webhook telegram bot PHP

Is it possible send other variables with sendMessage method to webhook?

for example setting the todo variable:

function processMessage($message) {
  // process incoming message
  $message_id = $message['message_id'];
  $azione = $message['todo'];
  $chat_id = $message['chat']['id'];
  $firstname = isset($message['chat']['first_name']) ? $message['chat']['first_name'] : "";
  $lastname = isset($message['chat']['last_name']) ? $message['chat']['last_name'] : "";

  if (isset($message['text'])) {
    $text = $message['text'];
    if (strpos($text, "/start") === 0) {
    apiRequestJson("sendMessage", array('chat_id' => $chat_id, "text" => 'Benvenuto '.$firstname.' '.$lastname.' sul BOT di MIMANCHITU, dimmi cosa vuoi fare ['.$azione.']?', 'todo' => "fai qualcosa", 'reply_markup' => array(
        'keyboard' => array(array('/consulta', '/guide')),
        'one_time_keyboard' => true,
        'resize_keyboard' => true)));
    } 
}

不可以,除了文档中定义的变量外,您不能发送任何其他变量。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM