In CF10 we had introduced cfoauth tag which helped in social login integration. Lets use it to build a simple facebook app which will download your facebook profile's pic, add some image effects to it and post it to facebook.

1. First we need to ask user to login via facebook so that we can fetch his profile image.

<cfoauth type="facebook" clientid='YOUR_CLIENT_ID'   secretkey="YOUR_SECRET_KEY_HERE"  result="r" scope="" redirecturi="REDIRECT_URL">

 

2. Not lets set this info into some variable 

<cfset Session.fbinfo = #r#>

 

3. Use cfhttp tag to download the image

<cfset thisPath=ExpandPath("*.*")>

<cfset thisDirectory=GetDirectoryFromPath(thisPath)>

<cfhttp method="Get" url="http://graph.facebook.com/#Session.fbinfo.id#/picture?type=large" path="#thisDirectory#" file="final.jpg">

 

4. Now lets use cfimage tage to do various image manipulations 

<cfimage action='resize' height='#height#' width='#width#' source='#thisDirectory#/final.jpg' destination='#thisDirectory#/final.jpg' overwrite=true> 

<cfimage action='rotate' angle='#angle#' source='#thisDirectory#/final.jpg' destination='#thisDirectory#/final.jpg' overwrite=true> 

<cfimage action='border' thickness='#thick#' color='#color#' source='#thisDirectory#/final.jpg' destination='#thisDirectory#/final.jpg' overwrite=true> 


5. Save the image 

<cfimage source="#image#" action="write" destination="#thisDirectory#/final.jpg" overwrite="yes">

6. Lastly post this image to Facebook 

<cfhttp  url="https://graph.facebook.com/me/photos?access_token=#Session.fbinfo.access_token#" method="post" multipart="yes">
   <cfhttpparam type="file" name="source" file="#thisDirectory#\final.jpg">
</cfhttp>