【发布时间】:2017-06-22 15:55:53
【问题描述】:
我正在使用 hook.io 为电报编写一个自己的机器人来托管 php 脚本。我遇到的问题是 file_get_contents("php://input") 似乎总是为空,因为如果我尝试执行与更新相关的任何操作,机器人不会做出反应:
$updates = json_decode(file_get_contents('php://input') ,true);
if($updates['ok']){
//loop over all messages
foreach($updates['result'] as $key => $value){
if($value['message']['text']==="/test"){
$chat_id = $value['message']['chat']['id'];
$result = file_get_contents( $apiURL . $apiToken . '/sendMessage?chat_id=' . $chat_id . '&text=test');
}
}
}
谁能告诉我这个有什么问题?
【问题讨论】:
-
你想在你的后端做 POST 吗?如果不是电报的查询 php://input 还是空的?
标签: php bots telegram telegram-bot php-telegram-bot