A possible reason could be that allow_url_fopen
might be disabled (quoting) :
This option enables the URL-aware
fopen wrappers that enable accessing
URL object like files.
You can check using the phpinfo()
function, to see if it's enabled or not.
If it's not enabled, you'll have to use another solution to send the HTTP request that fetches that remote content.
Using curl might be a solution, for instance ; see curl_exec
for a quick example, and curl_setopt
for a list of all possible options.
Here's what a simple request would look like, though :
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://feeds.reuters.com/Reuters/PoliticsNews?format=xml");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$feed = curl_exec($ch);
curl_close($ch);
This will get you the content of the feed in $feed
-- but check the manual page of curl_setopt
: there are so many options that going through the list cannot be a bad idea.
Still, as a precaution, before going this way, you might want to check if curl is enabled, is the output of phpinfo()
...