使用php在电报上创建自己的机器人

我几天前见过 this tutorial on youtube.
这非常有趣,所以我决定制作一个自己的机器人.
我使用教程中的代码作为模板:
<?php

$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”.

如果你使用自签名的ssl你必须指向ssl路径,
在用实际数据填充之后使用ssh运行此命令,
curl -F "url=https://example.com/myscript.php" -F "certificate=@/etc/apache2/ssl/apache.crt" https://api.telegram.org/bot<SECRETTOKEN>/setWebhook

相关文章

文章浏览阅读8.4k次,点赞8次,收藏7次。SourceCodester Onl...
文章浏览阅读3.4k次,点赞46次,收藏51次。本文为大家介绍在...
文章浏览阅读1.1k次。- php是最优秀, 最原生的模板语言, 替代...
文章浏览阅读1.1k次,点赞18次,收藏15次。整理K8s网络相关笔...
文章浏览阅读1.2k次,点赞22次,收藏19次。此网络模型提供了...
文章浏览阅读1.1k次,点赞14次,收藏19次。当我们谈论网络安...