homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Error Capture RSS Feed using PHP

 8:26 am on Sep 13, 2010 (gmt 0)

I access a RSS feed and the content is displayed in my website using PHP. There are times when there is no result from the RSS feed. How do i capture this so that i can display data from another source when the RSS feed fails.

I would like to capture the following when i access the RSS Feed :
1> Blank Result / No Result (Server us Up and running)
2> Server Response Very Slow or Server Down
3> Errors (Server us Up and running)

Please guide.



 7:11 pm on Sep 19, 2010 (gmt 0)

You connect to another site in order to retrieve the feed. If you are using say fsockopen you can setup a timeout and the function returns accepts a couple of parameters for the error codes

$fp=@fsockopen('tcp://'.$domain, 80, $errno, $errstr, 5);

So you can determine if the function failed or not and what the error is. Also you could cache the results daily instead of getting the feed with each request.

If the fp is false meaning the call failed then you could try another page to get your feed from. The 5th parameter is the timeout in secs. You could set it up so the code won't wait too long for a connection.

if( !$fp ) {
// Fetch alternative feed


 4:36 am on Sep 20, 2010 (gmt 0)

How do i cache the result ? Do you mean to save it in a Database and retrieve ?


 8:30 am on Sep 20, 2010 (gmt 0)

yes or in a file.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved