Telegram + PHP (Windows 7):无法打开流:HTTP 请求失败!HTTP/1.1 404 未找到

Ces*_*are 5 php apache2.4 php-5.6 telegram telegram-bot

我正在尝试迈出 Telegram 的第一步,而且我也是 PHP 的新手......

我已经在我的 Windows 7 电脑上配置了带有 PHP 5.6.14 和 SSL 的 Apache 2.4,并且它在 http 和 https 中运行良好。

然后我尝试遵循此 Telegram Bot 教程https://www.youtube.com/watch?v=hJBYojK7DO4。一切都工作正常,直到我必须创建一个像这样的简单 PHP 程序

<?php
  $botToken = "<my_bot_token>";
  $website = "https://api.telegram.org/bot".$botToken; 
  $update = file_get_contents($website."/getUpates"); 
  print_r($update);
?>
Run Code Online (Sandbox Code Playgroud)

当我尝试输入浏览器时

https://localhost/Telegram/MyYouTubeTutorialBot/YouTubeTutorialBot.php
Run Code Online (Sandbox Code Playgroud)

响应是

Warning: file_get_contents(https://api.telegram.org/<my_bot_token>/getupates): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in <my_php_file_location> on line 6
Run Code Online (Sandbox Code Playgroud)

我在网上搜索了类似的问题,但没有解决任何问题:最有趣的响应是这个问题file_get_contents - failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found但我不明白如何使其适应我的情况。

在其他回复中,建议使用curl,但我想解决持续的file_get_contents 函数。

我认为这不是 PHP 问题,而是我的配置中的某个地方的问题......但我不知道在哪里

有什么建议么?

预先非常感谢

切萨雷

添加注释

正如 @aeryaguzov 在评论中建议的那样,我的原始代码中有一个拼写错误......

这是现在可以使用的固定代码......

<?php
  $botToken = "<my_bot_token>";
  $website = "https://api.telegram.org/bot".$botToken; 
  $update = file_get_contents($website."/getUpdates"); 
  print_r($update);
?>
Run Code Online (Sandbox Code Playgroud)

Rao*_*ffy 2

这不是你的配置中的 PHP 问题。该错误意味着该文件https://api.telegram.org/<my_bot_token>/getupates不存在。

  • 我不这么认为,因为在浏览器中放入相同的 http 请求会给出正确的响应...... (2认同)