phptelegramapache2.4php-5.6telegram-bot

Telegram + PHP (Windows 7): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found


I'm trying to move my first steps in Telegram and I'm also a newbie in PHP ......

I've configured, on my Windows 7 pc, Apache 2.4 with PHP 5.6.14 and SSL and it's working fine in http and https.

Then I've tried to follow this Telegram Bot Tutorial https://www.youtube.com/watch?v=hJBYojK7DO4. Everything works fine until when I have to create a simple PHP program like this one

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

When I try to put in my browser

https://localhost/Telegram/MyYouTubeTutorialBot/YouTubeTutorialBot.php

the response is

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

I've searched on the web for similar issues but nothing has solved: the most interesting response is in this question file_get_contents - failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found but I don't understand how to adapt it to my case.

In others responses there is the suggestion to use curl but I'd like to solve continuing file_get_contents function.

I think that it's not a PHP problem but something in my configurations somewhere ... bu I don't know where

Any suggestions?

Thank you very much in advance

Cesare

NOTE ADDED

There was a typo spelling error in my original code as @aeryaguzov suggest in the comments ....

Here you're the fixed code that works right now ...

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

Solution

  • It's not a PHP problem something in your configurations. the error means that the file https://api.telegram.org/<my_bot_token>/getupates does not exist.