Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

951
Visualizações
PHP: file_get_contents(): failed to open stream error - works on test XAMPP test server, not live

I’m creating a PHP application that for a movie theater that, when accessed by a user, fetches an external XML document, saves it to our server. That XML file is then used to load the showtimes and other movie information. If the file on our server is older than 15 minutes, it’ll be overwritten, otherwise, it’ll load the existing one. I already pretty much finished the application, and it works perfect on my XAMPP test server, however it fails to work on the live server.

The external XML file is located at this URL: http://45502.formovietickets.com:2235/showtimes.xml. Our server that I am trying to save the file to is on one of HostGator’s Linux-based servers. Using PHP’s curl functions, I have been able to successfully load the XML file on the XAMPP test server only. On the live server, it simply fails to connect.

I feel like it might be an some sort of access restriction on the formovietickets.com server, but the people behind it insist there isn't any sort of restriction going on. Does anyone know a work around for this issue?

<?php

$url = 'http://45502.formovietickets.com:2235/showtimes.xml';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if(curl_exec($ch) === false) {
    echo 'Curl error: '.curl_error($ch);
} else {
    echo 'Retrieved file with no errors!';
}
curl_close($ch);

?>

What Have I Tested?

  • I’ve tried transferring the php.ini file over from XAMPP to the live server and it still fails.
  • I was able to successfully retrieve an XML file located on another external server.
  • I’ve tested the code on a Windows-based server and the problem persists.

NOTE: If you load the URL more than a couple times from the same IP address in less than 15 minutes, you’ll get an error saying “Too many requests from this IP address”. Just saying in case you try testing it out.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

My guess is that your hoster is blocking outbound access to non-standard ports like 2235 in their firewall. If that is the case, you should ask them to open that port and hope that they are willing to do so. If they aren't, then you'll have to come up with another solution to get the file on the server, like using a proxy or pushing the file to the server instead of fetching it.

over 4 years ago · Santiago Trujillo Relatório

0

Did you check the /etc/hosts file, on Windows it's at C:\Windows\System32\Drivers\etc\hosts, it might be causing formovietickets.com to resolve to a different IP, and it takes priority over the DNS server, speaking of which, try changing your DNS server.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda