Forum
How to validate an RSS feed?
2011-03-19 02:21:30
cheeko
Hi,
Great Rss reader.
I need to validate the feed url before its used. If its not a legit feed php errors are printed on screen. Id like to avoid this.
How can i validate the feed url?
thanks for any help you can give
2011-03-21 02:34:27
scriptol
Hello
Put a @ sign before the PHP function to avoid a error message.
This will be added to the next version.
2011-03-21 20:24:34
cheeko
thank you for your response.
I have done what you suggested and no more error message. But now if the feed is not a genuine feed the user gets a blank white screen where the error messages were. Is there anyway to validate the feed automatically and if its not legit then dont execute the function. I have it set up so users can add there own feeds and im sure people are bound to put in a bad feed at some point. I would rather it tell them that the feed is bad then show errors or a white screen.
Basically how can i check if the feed is valid. Is it even possible?
could i just wrap the function with something like
if(function has fatal error){tell user their feed sucks;}else{execute function;}
Thanks for any help you can offer me
:D
2011-03-22 14:23:23
scriptol
The feed is retrieved with this function, in RSS_Retrieve:
$doc->load($url);It returns false if the feed is not loaded. So, add a test:
if($doc->load($url) == false) return false;At the end of the function, add:
return true;And in the main function, RSS_Display:
if(!RSS_Retrieve($url)) return false;