defeated Posted November 16, 2010 Share Posted November 16, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/218860-parsing-feedburner-rss-feed-with-simplexml/ Share on other sites More sharing options...
lur Posted November 16, 2010 Share Posted November 16, 2010 Maybe cURL isn't following redirections, have a look at CURLOPT_FOLLOWLOCATION (http://www.php.net/manual/en/function.curl-setopt.php) Quote Link to comment https://forums.phpfreaks.com/topic/218860-parsing-feedburner-rss-feed-with-simplexml/#findComment-1135110 Share on other sites More sharing options...
defeated Posted November 17, 2010 Author Share Posted November 17, 2010 Perfect! Thank you. I just added in the line curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); and it worked perfectly. Quote Link to comment https://forums.phpfreaks.com/topic/218860-parsing-feedburner-rss-feed-with-simplexml/#findComment-1135266 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.