Skip to content

Instantly share code, notes, and snippets.

/flickr.cfc Secret

Created Dec 3, 2010
What would you like to do?
Flickr Collections integration for the XML Flash Slideshow v4 from
This script is used to integrate Flickr collections with the XML Flash Slideshow v4 from See the above URL to learn
more about this integration.
Original Author : Roben Rajan
Date : 30 Nov 2010
Powered By : Exalt Integral Solution
*** Note that this version has been modified slightly from the original.
<cfcomponent displayname="flickr" output="false" hint="Component for Flickr Collection">
<cffunction name="init" access="public" returntype="string" output="false">
<cfargument name="userID" type="string" required="yes" default="">
<cfargument name="apiKey" type="string" required="yes" default="">
<cfargument name="collectionID" type="string" required="yes" default="">
<cfset this.userID = arguments.userID>
<cfset this.apiKey = arguments.apiKey>
<cfset this.collectionID = arguments.collectionID>
<cfset this.thumbSize = 's'><!---thumbSize can be 's' or 't'--->
<cffunction name="getPhotos" access="remote" returntype="string" output="false">
<!---<cfsetting enablecfoutputonly="true">--->
<!---<cfcontent type="text/xml" reset="yes">--->
<!---<cfset init(userID = "PLACE_USER_ID_HERE", apiKey = "PLACE_API_KEY_HERE", collectionID = "PLACE_COLLECTION_ID_HERE")>--->
<cfset init(userID = arguments.userID, apiKey = arguments.apiKey, collectionID = arguments.collectionID)>
<cfset output = getFlickrCollectionSourceString()>
<!---<cfset output = XMLParse(getPage(output))>--->
<cfreturn output>
<cffunction name="getFlickrCollectionSourceString" access="public" hint="The public function for calling the flick Collection" output="false">
<!---Get all photosets, so we have the thumb, title and desc for each "gallery"--->
<cfset variables.url = "">
<cfset xml = getPage(variables.url)>
<cfset xmlobj = xmlParse(xml)>
<cfloop from="1" to="#ArrayLen(xmlobj.rsp.photosets.xmlchildren)#" index="i">
<cfset attr = xmlobj.rsp.photosets.photoset[i].xmlattributes>
<cfset id =>
<cfset thumb = "">
<cfset title = xmlobj.rsp.photosets.photoset[i].title.xmltext>
<cfset description = xmlobj.rsp.photosets.photoset[i].description.xmltext>
<cfset photosetInfo[id] = structnew()>
<cfset photosetInfo[id].thumb = thumb>
<cfset photosetInfo[id].title = title>
<cfset photosetInfo[id].description = description>
<!---Get the photos--->
<cfset variables.url = ''>
<cfset xml = getPage(variables.url)>
<cfset xmlobj = xmlParse(xml)>
<cfset sources = arraynew(1)>
<cfloop from="1" to="#ArrayLen(xmlobj.rsp.collections.collection.xmlchildren)#" index="i">
<cfset attr = xmlobj.rsp.collections.collection.xmlchildren>
<cfset set = attr[i].xmlattributes>
<cfset sourceURL = ''><!---Build Flickr photoset API URL--->
<!---Append the special information strings--->
<cfset info = evaluate("")>
<cfset sourceURL = sourceURL & '&xfs4t=#URLEncodedFormat(info.thumb)#&xfs4ti=#URLEncodedFormat(info.title)#&xfs4d=#URLEncodedFormat(info.description)#'>
<cfset ArrayAppend(sources,sourceURL)>
<cfreturn arraytolist(sources,",")>
<cffunction name="getPage" access="private" hint="Get the Flickr page as XML" output="false">
<cfargument name="url" type="string" required="yes" hint="url string">
<cfhttp url="#arguments.url#">
<cfreturn cfhttp.filecontent>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment