Php 电报bot开关()中的更新

Php 电报bot开关()中的更新,php,webhooks,telegram-bot,php-telegram-bot,telegram-webhook,Php,Webhooks,Telegram Bot,Php Telegram Bot,Telegram Webhook,我在.php文件中编写了这段代码,我在其中设置了运行良好的webHook $token=“我的令牌”; $website=”https://api.telegram.org/bot" . $代币"/"; $updates=文件\u获取\u内容(“php://input"); $updates=json_decode($updates,true); $text=$updates[“message”][“text”]; $chatID=$updates[“message”][“chat”][“id”

我在.php文件中编写了这段代码,我在其中设置了运行良好的webHook

$token=“我的令牌”;
$website=”https://api.telegram.org/bot" . $代币"/";
$updates=文件\u获取\u内容(“php://input");
$updates=json_decode($updates,true);
$text=$updates[“message”][“text”];
$chatID=$updates[“message”][“chat”][“id”];
开关($text){
案例“/证明”:
如果(支票($chatID)){
sendMessage($chatID,“确定吗?演示只提供一次。请写确认以继续”);
开关($text){
案例“确认”:
...
打破
} 
}
第二个
开关()
不工作。为什么?我能做什么?
我知道我应该更新
$text
的值,但我不知道如何更新我认为错误在于您如何设置问题。 每个bot输入都是对那个WebHook的一个调用。那么$text就不能以这种方式被aggornato了

您还应该在第一个开关中包含第二个开关的“case”

$token = "my token";
$website = "https://api.telegram.org/bot" . $token . "/";
$updates = file_get_contents("php://input");
$updates = json_decode($updates, true);
$text = $updates["message"]["text"];
$chatID = $updates["message"]["chat"]["id"];

switch($text){
    case "/prova_gratuita":
        if(check($chatID))    sendMessage($chatID, "Are you sure? Demo is available only one time. Write confirm to continue");
    case "confirm":
    ...

 }

每次你向bot发送消息时,他都会打电话给WebHook。因此,要更改$updates的状态,即使脚本中的$text也应该重新启动

为什么要工作?对不起,我还没有完成这个问题。@u\u mulderI理解。谢谢每次你向bot发送消息时,他都会打电话给WebHook。所以要更改$updates,因此即使脚本应该重新启动的$text也是如此