Callback_query不起作用(Telegram php bot)

时间:2019-07-18 19:46:56

标签: php callback telegram telegram-bot php-telegram-bot

我现在正在创建一个电报机器人,我制作了inline_keyboard(带有回调数据),我希望当我按下“ Developer”按钮时它将改变消息,但是当我要检查callback_data值并有一个响应它什么也没做

$query = $update['callback_query'];
$queryid = $query['id'];
$queryUserID = $query['from']['id'];
$querydata = $query['data'];

// Query
$tastierainline = 'reply_markup={"inline_keyboard": [[{"text":"Developer","callback_data":"Developer"},{"text":"Top10 ?","callback_data":"Top10"}]]}';

if ($querydata == "Developer") {
    editMessage(
        $userID, 
        "Bot developed by @Herossandro and @KiroWasHere",
        $messageIDBot, 
        'reply_markup={inline_keyboard: [[{"text":"Home","callback_data":"Home"}]]}'
    );
}

我希望该机器人将消息修改为“由@Herossandro和@KiroWasHere开发的机器人”,但是当我按下“开发者”按钮时,它什么也没做(加载了一段时间,但什么也没做)

1 个答案:

答案 0 :(得分:0)

1-您忘了第二个inline_keyboard

的双引号

2-您不应该使用\"吗?

$query = $update['callback_query'];
$queryid = $query['id'];
$queryUserID = $query['from']['id'];
$querydata = $query['data'];
// Query
$tastierainline = 'reply_markup={\"inline_keyboard\": 
[[{\"text\":\"Developer\",\"callback_data\":\"Developer\"},{\"text\":\"Top10 
?\",\"callback_data\":\"Top10\"}]]}';
if ($querydata == "Developer") {
    editMessage($userID, "Bot developed by @Herossandro and @KiroWasHere", 
        $messageIDBot, 'reply_markup={inline_keyboard: 
        [[{\"text\":\"Home\",\"callback_data\":\"Home\"}]]}');
}