我几天前见过
this tutorial on youtube.
这非常有趣,所以我决定制作一个自己的机器人.
我使用教程中的代码作为模板:
$bottoken = "*****";
$website = "https://api.telegram.org/bot".$bottoken;
$update = file_get_contents('php://input');
$updatearray = json_decode($update, TRUE);
$length = count($updatearray["result"]);
$chatid = $updatearray["result"][$length-1]["message"]["chat"]["id"];
$text = $updatearray["result"][$length-1]["message"]["text"];
if($text == 'hy'){
file_get_contents($website."/sendmessage?chat_id=".$chatid."&text=hello");
}
elseif($text == 'ciao'){
file_get_contents($website."/sendmessage?chat_id=".$chatid."&text=bye");
}
如果我手动执行脚本,脚本会起作用.但是,当我使用webhook时,它不再起作用了.教程说$update = file_get_contents(‘php:// input’);是$update = file_get_contents($website.“/ getupdates”);之前使用的正确方法.我的问题如何使用php://输入自动执行我的脚本?该脚本位于“one.com”的服务器上,证书也来自“one.com”.