我正在尝试在 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);
?>
当我尝试放入浏览器时
https://localhost/Telegram/MyYouTubeTutorialBot/YouTubeTutorialBot.php
回应是
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
我在网上搜索过类似的问题,但没有解决任何问题:最有趣的回答是这个问题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);
?>