PHP://输入为空

PHP://Input is Empty

我正在为 telegramm 编写一个自己的机器人,使用 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');
     }
  }

}

谁能告诉我这个有什么问题吗?

我这样更正:

$updates = json_decode(file_get_contents('php://input') ,true);

if($updates['update_id']){

 if($updates['message']['text']==="/test"){
   $chat_id =   $updates['message']['chat']['id'];
   $result = file_get_contents( $apiURL . $apiToken . '/sendMessage?chat_id=' . $chat_id . '&text=test');
 }
}

消息总是一个,所以我删除了foreach