如何使用 php 在电报机器人中进行简单的测验和按钮回答?
how to make simple quiz and button answer in telegram bot with php?
我想做一个简单的问题和选择题的答案,我想要的结果是这样的:this is picture for desired the multiple choice button
但结果并不像我想要的这是我的代码结果的图片:this is picture for not desired result
这是我试过的代码:
<?php
$token = "##################################";
$website = "https://api.telegram.org/bot".$token;
$array = array(array("1","2","3"));
$btn = array("keyboard" => $array,"hide_keyboard" => true,'selective' => true,);
$reply = json_encode($btn);
$url = $website."/sendmessage?chat_id=$chatIdtext=select : &reply_markup=".$reply;
file_get_contents($url);
?>
试试这个代码,也许结果就是你想要的。
<?php
$token = "######################################";
$website = "https://api.telegram.org/bot".$token;
$name1 = 'das';
$name2 = 'dsa';
$placeId1 = '1';
$placeId2 = '2';
$keyboard = [
'inline_keyboard' => [[['text' => $name1, 'callback_data' => $placeId1]], [['text' => $name2, 'callback_data' => $placeId2]]],
];
$reply = json_encode($keyboard);
$url = $website."/sendmessage?chat_id=130434215&text=select : &reply_markup=".$reply;
file_get_contents($url);
?>
我想做一个简单的问题和选择题的答案,我想要的结果是这样的:this is picture for desired the multiple choice button
但结果并不像我想要的这是我的代码结果的图片:this is picture for not desired result
这是我试过的代码:
<?php
$token = "##################################";
$website = "https://api.telegram.org/bot".$token;
$array = array(array("1","2","3"));
$btn = array("keyboard" => $array,"hide_keyboard" => true,'selective' => true,);
$reply = json_encode($btn);
$url = $website."/sendmessage?chat_id=$chatIdtext=select : &reply_markup=".$reply;
file_get_contents($url);
?>
试试这个代码,也许结果就是你想要的。
<?php
$token = "######################################";
$website = "https://api.telegram.org/bot".$token;
$name1 = 'das';
$name2 = 'dsa';
$placeId1 = '1';
$placeId2 = '2';
$keyboard = [
'inline_keyboard' => [[['text' => $name1, 'callback_data' => $placeId1]], [['text' => $name2, 'callback_data' => $placeId2]]],
];
$reply = json_encode($keyboard);
$url = $website."/sendmessage?chat_id=130434215&text=select : &reply_markup=".$reply;
file_get_contents($url);
?>