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?
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.
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.