Reputation: 253
I'm using simplexml_load_file()
to grab the contents of an RSS feed:
$rss = simplexml_load_file('http://www.iolproperty.co.za/roller/news/feed/entries/rss');
This works as expected on my local server but fails silently when deployed to my client's production server, returning an empty result.
The phpinfo()
function says that SimpleXML support is enabled, and it does seem that I'm allowed to access remote files (cURL functions work just fine). I've also tried loading different RSS feeds. Again, they work locally but return empty when deployed.
Upvotes: 1
Views: 3944
Reputation: 14173
A production server might have outgoing internet request blocked to prevent abuse. Another reason could be that its a different PHP version or some mods are not included in the configuration. Use error reporting to see the error message
error_reporting(E_ALL);
//UPDATE
You could also check if you get a value back from the server like
$c = implode('', file('http://www.iolproperty.co.za/roller/news/feed/entries/rss'));
print $c;
$rss = simplexml_load_string($c);
and check what the others are saying, check if allow_url_fopen
option is enabled
Upvotes: 1
Reputation: 5731
simplexml_load_file
need that allow_url_fopen
directive is enabled in php.ini
if you want to load an external file. Curl functions does not need this directive, so it works for you.
Upvotes: 5
Reputation: 50603
You have to set allow_url_fopen option enabled for that to work.
Upvotes: 1