AndyJarrett

isValidRss CFC

Update: This project is now hosted on GitHub @ http://github.com/andyj/isValidRSS-CFCI was mucking around last night after finding out my feed wasnt valid, and created a validation CFC.The code is simple, but its just an idea if anyone wants to play around with it. It returns a boolean result,so i was thinking if it returns TRUE, then display "valid rss image" else "invalid, please email webmaster"?Here's the code for it, or if you want you can download it

<cfcomponent displayname="Check if valid RSS feed" hint="I take a URL and check it against ATOM to see if it is valid">
   <cffunction name="isValidRss" access="public" returntype="string" displayname="isValidRss" hint="I check an RSS Feed to see if its valid">
      
      <cfset var validationResult = FALSE>
      
      <cfargument name="rssUrl" type="string" required="true">
      
      <!--- Go of and validate the feed --->
      <cfhttp
         method="get"
         url="http://feedvalidator.org/check?url=#rssUrl#"
         resolveurl="yes"
         throwonerror="yes">

   
      <cfif findNoCase("Congratulations!", cfhttp.FileContent)>
         <cfset validationResult = TRUE>
      </cfif>
   
      <cfreturn validationResult>
   </cffunction>
</cfcomponent>