homepage Welcome to WebmasterWorld Guest from 54.205.119.163
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

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
pemba76




msg:4201052
 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.

 

enigma1




msg:4203934
 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

eg:
$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
}

pemba76




msg:4204067
 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 ?

enigma1




msg:4204107
 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