<cfinclude template="config.cfm">

<cfset flickr = createobject("component", "CFlickr.Flickr")>
<cfset flickr.init(apikey, secret, token)>

<cfinclude template="header.cfm">

<h1>Example 5</h1>

<cfoutput>

<cfset ii = flickr.getInterestingnessInterface()>
<cfset psi = flickr.getPhotosetsInterface()>
<cfset ppli = flickr.getPeopleInterface()>

<cfif isdefined("url.photoset_id") AND isdefined("url.user_id")>

	<cfset photoset = psi.getInfo(url.photoset_id)>
	<cfset arrayPhotos = psi.getPhotos(url.photoset_id).getPhotos()>
	<cfset owner = ppli.getInfo(url.user_id)>
	
	<h3>#owner.getUsername()#'s > #photoset.getTitle()#</h3>

	<cfloop from="1" to="#arraylen(arrayPhotos)#" index="i">
		<img src="#arrayPhotos[i].getPhotoUrl(arrayPhotos[i].SIZE_SMALL_SQUARE)#" />
	</cfloop>

<cfelse>

	<cfset photos = ii.getList(per_page=1,page=randrange(1, 500)).getPhotos()>  <!--- get a user by finding a random interesting photo --->
	<cfset photo = photos[1]>
	<cfset arraySets = psi.getList(photo.getOwner().getId())>
	<cfset owner = ppli.getInfo(photo.getOwner().getId())>
	
	<h3>#owner.getUsername()#'s public photo sets</h3>

	
	<cfloop from="1" to="#arraylen(arraySets)#" index="i">
		<cfset primary = arraySets[i].getprimaryPhoto()>
		<div>
		<img src="#primary.getPhotoUrl(primary.SIZE_SMALL_SQUARE)#" />
		<a href="?photoset_id=#arraySets[i].getId()#&user_id=#owner.getId()#">#arraySets[i].getTitle()#</a>
		</div>
	</cfloop>
	
</cfif>

</cfoutput>