小编Akr*_*tov的帖子

如何在 PHP 中从 Telegram 获取 callback_data

我想从响应中获取回调数据,但数组为空。

我试图在消息callback_data数组中显示。

这是我的代码:

$botToken = "token";
$botAPI = "https://api.telegram.org/bot" . $botToken;
$update = json_decode(file_get_contents('php://input'), TRUE);
$message = $update["message"]["text"]
$chatId = $update["message"]["chat"]["id"];
$callback_query = $update['callback_query'];
$callback_query_data = $callback_query['data'];
$url = $botAPI . '/sendMessage?chat_id=' . $chatId . '&text=';

if(isset($callback_query)){
    file_get_contents($url . $callback_query_data);
}

if($message == "/start"){
    $parameters = array('chat_id' => $chatId, "text" => "????????????. ???????? ????. \n???????. ??????? ??????? ?????.\nHi! Select your language.");
    $parameters["method"] = "sendMessage";
    $keyboard = ['inline_keyboard' => [[
        ['text' => "??????", 'callback_data' => 'tajik'],
        ['text' =>  "???????", …
Run Code Online (Sandbox Code Playgroud)

php telegram-bot php-telegram-bot

5
推荐指数
1
解决办法
3115
查看次数

标签 统计

php ×1

php-telegram-bot ×1

telegram-bot ×1