Error reading XML file

Asked

Viewed 377 times

0

Good people, every time I put to read an XML file on my localhost to return some XML response, everything works fine but, when I host this page, it gives error. What can it be?

The error that appears is this:

Warning:simplexml_load_file(http://painel.foxsolucoes.net/api/VFZSTmVrMTZaejA9KzU=) [Function.simplexml-load-file]: failed to open stream: Connection timed out in /home/plusr582/public_html/playing.php on line 2

Warning: simplexml_load_file() [Function.simplexml-load-file]: I/O Warning : failed to load External Entity "http://painel.foxsolucoes.net/api/VFZSTmVrMTZaejA9KzU=" in /home/plusr582/public_html/playing.php on line 2

  • Have you tried a little XML? Yours php.iniis the same in your host and localhost?

2 answers

2

It doesn’t seem to be blocking, copy this code below

$url = 'http://painel.foxsolucoes.net/api/VFZSTmVrMTZaejA9KzU=';
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, "<xml>here</xml>" );
$result = curl_exec($ch);
curl_close($ch);

$xml = simplexml_load_string($result);
$xml_arr_Content = unserialize(serialize(json_decode(json_encode((array)$xml),1)));

echo '<pre>';
var_dump($xml_arr_Content);exit;

If it doesn’t work check if there is no php extension missing from your machine.

0

The link is accessible and loads normally.

Probably your server’s IP may be blocked.

There is nothing to do in this case, except contact the administration of the site.

  • Friend continued the same problem. Would have another way to solve this?

  • updated the response

Browser other questions tagged

You are not signed in. Login or sign up in order to post.