<cfinclude template="config.cfm">

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

<cfinclude template="header.cfm">
<h1>Example 1</h1>
<p><strong>NOTE: </strong>You must set your API Key and shared secret in config.cfm and point 
	your callback url (<a href="http://www.flickr.com/services/api/keys">here</a>) for this 
	API Key to this page in order to use this example </p>

<cfif isdefined('url.frob')>

	<cfset auth = ai.getAuthToken(url.frob)>
	
	<!---
	This should be the page set as your callback url for this API key.
	Put your processing here.
	--->

	<cfoutput>
	<p>Below is some of the information returned from Flickr now that the user has been authenticated.<br />
	You can store the UserID and Token so that in future users will not need to 
	authenticate to use your web application. </p>
	
	
	<strong>Token:</strong> #auth.getAuthToken()#<br />
	<strong>Permission:</strong> #auth.getPermission()#<br />
	<strong>Username:</strong> #auth.getUser().getUserName()#<br />
	<strong>User ID:</strong> #auth.getUser().getId()#
	</cfoutput>
	
<cfelse>

	<cfset loginurl1 = ai.getAuthUrl("read")>
	<cfset loginurl2 = ai.getAuthUrl("write")>
	
	<cfoutput>
	<p>Follow the url below, you will be asked to login to your Flickr account. <br />
	 You will then be returned to the callback url that you set when creating your API key on Flickr.  <br />
	 Set the callback url to the url of this page for the example to work correctly,</p>
	<p><strong>Request Read Permission:</strong> <a href="#loginurl1#">#loginurl1#</a></p>
	<p>			<strong>Request Write Permission :</strong> <a href="#loginurl2#">#loginurl2#</a>
	</p>
	</cfoutput>

</cfif>