'I can load xml file at localhost but not in production server

Until today, I was able to read daily exchange rates form Turkish Central Bank xml url. However, today, customers informed us that they cannot make online transaction on our website.Then I checked and realized that I can not read the contents of xml file. I am using php for that. Here is the code:

 $tcmb = ("https://www.tcmb.gov.tr/kurlar/today.xml"); 
 if (false === $tcmb) {
     echo "Failed loading XML\n";
     foreach(libxml_get_errors() as $error) {
         echo "\t", $error->message;
     }
 } 
 else { 
 $euro_satis = $tcmb->Currency[3]->BanknoteSelling;
 }

This returned with a "failed to load external entity" error.

Then I tried curl in order to make sure if file is closed to external reach.

 $ch = curl_init();
 curl_setopt($ch,CURLOPT_URL,"https://www.tcmb.gov.tr/kurlar/today.xml"); 
 curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); 
 $output = curl_exec($ch); 
 curl_close($ch);
 $tcmb = simplexml_load_string($output);
 $euro_satis = $tcmb->Currency[3]->BanknoteSelling;

This returned null.

Then i tried both of the codes on local with Xampp (Apache Server) and both worked fine.

I tried to download the xml file from url. Again, it worked on local but not on production server. They all were working fine till today.

What could be wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source