【发布时间】:2017-02-14 21:42:24
【问题描述】:
我无法理解电报机器人 api 的 Reply_to_message 方法。这是我的代码:
<?php
define('API_KEY','My_token');
function bot($method,$datas=[]){
$url = "https://api.telegram.org/bot".API_KEY."/".$method;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,http_build_query($datas));
$res = curl_exec($ch);
if(curl_error($ch)){
var_dump(curl_error($ch));
}else{
return json_decode($res);
}
}
$update = json_decode(file_get_contents('php://input'));
if($update->message->text == '/start'){
bot('sendMessage',[
'chat_id'=>$update->message->chat->id,
'text'=>'Hello word!'
]);
}
当用户发送/启动机器人时,这里发送 hello world 文本。我想用户回复发送 hello world 的消息。我的意思是当用户发送/启动机器人回复到带有文本“Hello world!”的消息时
我正在使用 webhook。
【问题讨论】:
标签: telegram-bot