Click to search Andy Jarrett.co.uk RSS feed

Loading Twitter

isValidRss CFC

Update: This project is now hosted on GitHub @ http://github.com/andyj/isValidRSS-CFC I 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>

Comments Comments (0) | Print Print | Send Send | 2406 Views

If you like what you see on the website and/or this post has helped you out in some way please consider donating to help keep me in beer vodka. The donations are made through Paypal, which accepts almost any credit card or eCheck.

(Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC by Raymond Camden + Twitter @AndyJ + ColdFusion jobs + Contact Me + Snippets/Downloads + RSS .