0
votes

I'm trying to load a wordpress RSS feed using simplexml_load_file and failing.

I have a PHP script that lives on our internal web server (intranet) and a wordpress blog that lives on intranet/newsletter. I'm trying to pull the RSS feed from the blog into our intranet using the following code ad failing:

$rss = simplexml_load_file('intranet/newsletter/feed/');

This is the error I get:

Warning: simplexml_load_file(): I/O warning : failed to load external entity "intranet/newsletter/feed/" in /var/www/html/intranet/test.php on line 69

I've tried using

$rss = simplexml_load_file('http://intranet/newsletter/feed/');

with no success.

From a browser intranet/newsletter/feed/ works fine.

2
Is intranet representing something else? - dpk2442
stackoverflow.com/questions/9771666/… Verify ini_set('allow_url_fopen ','ON'); ? - ficuscr
php runs on the same machine that have browser pointing to intranet? - dev-null-dweller
Yes, ini_set('allow_url_fopen ','ON'); is present. - James J
@dev-null-dweller both the newsletter rss feed and the intranet are on the same internal web server. - James J

2 Answers

1
votes

From the comment:

can you try using server ip address (like http://1.2.3.4/newsletter/feed/) instead of intranet to see if it works?

For some reason php is unable to map intranet into IP. Do you have proper entry for intranet in /etc/hosts ?

0
votes

Try to use file_get_contents function

 $xml = simplexml_load_string(file_get_contents('http://intranet/newsletter/feed/'));