【发布时间】:2020-05-21 19:58:28
【问题描述】:
下面我报告了一个简单的代码,通过单击“当前位置”按钮,我可以知道我的当前位置。 发送位置后,我希望能够发送一条消息,显示该位置的纬度和经度。 我不知道如何与 Telegram 发送的位置进行交互,您能帮帮我吗?
<?php
define ('url',"https://api.telegram.org/bot[botToken]/");
$update= file_get_contents('php://input');
$update= json_decode($update, TRUE);
$chatId= $update['message']['from']['id'];
$text= $update['message']['text'];
$button= '[{"text":"Current location", "request_location": true}]';
position($chatId, "Click the button to share your location", $button);
function position($IdChat, $text, $tastiera){
$tastierino = '&reply_markup={"keyboard":['.$tastiera.'],"resize_keyboard": true,"one_time_keyboard": true}';
$url= url."sendMessage?chat_id=$IdChat&parse_mode=HTML&text=".urlencode($text).$tastierino;
file_get_contents($url);
}
?>
【问题讨论】:
标签: telegram telegram-bot php-telegram-bot