EasyCFM.COM ColdFusion Forums / Good Coding Tips! / Feed FLICKR images via RSS

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Feed FLICKR images via RSS

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

08-09-2007 @ 6:28 PM
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 146
Joined: Jun 2005

I'm not trying to advertise flickr and I don't want to help you break any image copyright laws, but rather help anyone that might need to feed their flickr images to their site. (It does save on bandwidth I believe /I hope)

Anyway here is code I learnt via easycfm tutorials and help from the boss Pablo

You figure it out, basically it is feeding a single image randomly from a selected flickr rss feed. Please modify to suit.

<!--- identify the xml link --->
// get the xml link from flickr
URLToPull = "http://api.flickr.com/services/feeds/photos_public.gne?id=87981700@N00&amp;lang=en-us&format=atom"; // Patricks Place

<!--- get it --->
<cfhttp url="#URLToPull#" method="get" timeout="15"></cfhttp>

<!--- process the xml --->
     XMLContent = trim(cfhttp.filecontent);
     XMLContent = XMLParse(XMLContent);

<!--- select which Image to get --->
<cfset i = randRange(1, ArrayLen(XMLContent.feed.entry))>

<!--- output it --->
<a href="#XMLContent.feed.entry.xmlChildren[2].xmlAttributes.href#" title="#XMLContent.feed.entry.title.xmlText# - Click to see full size photo">
<img name="FlickrImage" src="#XMLContent.feed.entry.xmlChildren[10].xmlAttributes.href#" class="pic-border" width="164" alt="Flickr Image">

I set a very small width 164px, please change to suit your needs, Also wrap it in a cftry tag to help any errors.


Website Designed and Developed by Pablo Varando.