I make a request to the server with the API and immediately get an answer. Link If I execute such code in PHP , then an error comes. What could be the problem and how to solve it?

 $url = 'http://185.47.152.162:82/prozone/gifts?session_id=1875c1e1642dcd03274b606f46343370'; $data = json_decode(file_get_contents($url)); echo '<pre>'.print_r($data).'</pre>'; 

Mistake

PHP Warning: file_get_contents ( http://185.47.152.162:82/prozone/gifts?session_id=1875c1e1642dcd03274b606f46343370 ): failed to open stream: Connection timed out

  • try using curl - webDev_
  • @webDev_, file_get_contents () allows you to customize the request headers;) - Visman
  • @webDev_, I tried cURL and JsonParse for JS (is the problem in IP a little). It still gave an error. - NTP
  • @erm, and now I have taken your code from the question for verification and executed it from localhost. The data returned, without any errors. You may have been blocked on the service. Maybe your ports are blocked by php. Can function access to external resources closed. - Visman
  • @Visman, access is not closed (because I get the API of other sites). The service is not blocked. And what about the ports? How to check them? And how to set up? - NTP

0