小编Moh*_*134的帖子

如何从 Telegram Bot 数据库中删除所有请求 (getUpdates)

你好,我的机器人继续向我发送消息。我的代码是:

while(true)
{
    header('Content-Type: text/html; charset=utf-8');
    $token= "MY-TOKEN";
    $url= "https://api.telegram.org/bot".$token."/getUpdates";
    $update = file_get_contents($url);
    $arrayUpdate= json_decode($update, true);
    foreach ($arrayUpdate['result'] as $key) {
            $chat_id = $key['message']['from']['id'];
            $command = $key['message']['text'];
    }
    if($command == "/start"){
        $text= "starting...";
        $url= "https://api.telegram.org/bot".$token."/sendMessage?chat_id=".$chat_id."&text=".$text;
        file_get_contents($url);
    }
}
Run Code Online (Sandbox Code Playgroud)

我的机器人向我发送无限消息我希望我的机器人在我使用它时向我发送消息然后停止并等待下一个请求。

php telegram-bot

1
推荐指数
1
解决办法
6960
查看次数

标签 统计

php ×1

telegram-bot ×1