php - "H"信件未发送至电报机器人

标签 php telegram-bot

有史以来最奇怪的问题 我正在尝试在 php 上创建一个 Telegram 机器人。

当我尝试发送给电报机器人“H”(H 字母前有空格,大写)时,它不起作用!未收到消息。

$text = ' H';
file_get_contents($website."/sendMessage?chat_id=".$chatId."&text=".$text);

当只有“H”(没有空格)时结束。它有效。

发生什么事了?

最佳答案

您需要转义网址中的文本:

file_get_contents($website."/sendMessage?chat_id=".$chatId."&text=".urlencode($text));

Documentation here

关于php - "H"信件未发送至电报机器人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37923586/

相关文章:

php - 将 MySQL 查询放在 try{ } 之外是否安全

telegram-bot - 有时机器人无法通过 id 提及用户

c# 无法创建 InlineKeyboardButton

telegram - 我的机器人如何从 Telegram 上的用户那里获取组 ID?

php - php echo 语句中的乘法

php - 如何在 Laravel Controller 中包含一些文件

php - 是否有可能找到与单个正则表达式重叠的匹配项?

php - 解析字符串 - 使用正则表达式或类似的东西?

Telegram Bot 有时需要用户身份验证

telegram - 错误请求 : sticker set name invalid