Folks, I hope your collective wisdom can help me. The WP forums weren't exactly brimming with support.
Here's the sitation. I have my home page at example.com/index.php
My WordPress blog is at example.com/blog
My WordPress RSS feed is at example.com/blog/feed
On /index.php, I want to show the last four entries from my WP blog. To do this I have tried using Magpie (I also tried Simplepie which just gave be blank pages), like so;
nclude_once($inc['magpierss']);
$url = 'blog/feed';
$rss = fetch_rss($url);
I have used variations of $url each resulting in an error message, as follows;
blog/feed results in
Warning: MagpieRSS: Failed to fetch blog/feed (HTTP Error: Invalid protocol "") in /var/www/vhosts/example.com/httpdocs/inc/magpierss/rss_fetch.inc on line 238
http://example.com/blog/feed results in
Warning: MagpieRSS: Failed to fetch http://example.com/blog/feed (HTTP Response: HTTP/1.1 404 Not Found ) in /var/www/vhosts/example.com/httpdocs/inc/magpierss/rss_fetch.inc on line 238
blog/wp-rss2.php results in
Warning: MagpieRSS: Failed to fetch blog/wp-rss2.php (HTTP Error: Invalid protocol "") in /var/www/vhosts/example.com/httpdocs/inc/magpierss/rss_fetch.inc on line 238
http://example.com/blog/wp-rss2.php and
Warning: MagpieRSS: Failed to fetch http://example.com/blog/wp-rss2.php (HTTP Response: HTTP/1.1 404 Not Found ) in /var/www/vhosts/example.com/httpdocs/inc/magpierss/rss_fetch.inc on line 238
$_SERVER['DOCUMENT_ROOT'].'/blog/wp-rss2.php' results in
Warning: MagpieRSS: Failed to fetch /var/www/vhosts/example.com/httpdocs/blog/wp-rss2.php (HTTP Error: Invalid protocol "") in /var/www/vhosts/example.com/httpdocs/inc/magpierss/rss_fetch.inc on line 238
It's boiled down to apparently being because Magpie uses Snoopy which uses fsockopen(). Obviously, being a WP feed it needs to be parsed by PHP so I'm presuming 'opening' it with fsockopen doesn't do that, just like fopen() wouldn't.
Oh and accessing both http://example.com/blog/feed and http://example.com/blog/wp-rss2.php both show the full, well-formed RSS feed as it should be.
So.... does ANYONE know of a way around this, or another feed parser I could use.
FYI allow_urls_fopen is disabled in my php.ini to prevent script injection vulnerabilities.
Before I finish I did try this; I created a file (/feed.php) which used a PHP include to include the RSS feed (with the intention of giving Magpie $url = '/feed.php'). Now, strangely it did include the feed but not all of it. The <items> tags and everything in between (the items!) were missing (yet the Channel and RSS tags were in place)! I used the exact same PHP-include in /index.php and it pulled in the entire feed, complete with Items. This one is particular bizarre - ideas on a post card.
Thanks very much in advance for your help... I'm really struggling with this one!