Jump to content

parsing feedburner rss feed with simplexml


defeated

Recommended Posts

Hi,

I've run into a problem, or rather users of the ap I'm developing are likely to run into a problem.

 

I'm using simplexml with curl to parse RSS feeds.  Mostly that works just fine.

 

The trouble I've run into is that if a user is using feedburner.  If they enter the feedburner url (http://feeds2.feedburner.com/blah) when asked for the feed they want parsed it is not a problem.

 

If however they give the original feed url (http://mysite/feed) then the parser cannot load the feed.

 

The relevant code is:

$settings['feed-url']='http://mysite/feed';

//Fetch the RSS feed
$ch = curl_init( $settings['feed-url'] );
if(!($ch)) echo "Could not initialise feed";
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if(!$feed = simplexml_load_string ( curl_exec($ch) )) echo "Could not load feed ".$settings ['feed-url'];
curl_close($ch);

 

That will result in the message displayed being "Could not load feed http://mysite/feed".

If I switched the feed to be http://feeds2.feedburner.com/blah then it would work perfectly.

 

I could tell people to just use their feedburner address, but it would be better if they could put in either.  My browser can handle it, so my ap should be able to handle it too.

 

Any ideas?  I can't find this problem mentioned anywhere.  :shrug:

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.