July 13, 2015
Creating a simple facebook app which manipulates your profile pic
Comments
(2)
July 13, 2015
Creating a simple facebook app which manipulates your profile pic
Newbie 12 posts
Followers: 0 people
(2)

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>

 

 

2 Comments
2015-07-13 08:58:49
2015-07-13 08:58:49

Interesting stuff, I haven’t used the cfoauth tag yet I’ll have to give it a shot. Thank you for the example

Like
2015-07-13 04:28:27
2015-07-13 04:28:27

Once again, could really have done with being proof read, for the prose and the code.
From just the first two parts:

“CF10 we had introduced” – “CF10 we have introduced”

“” – “”

I stopped reading there because then you started using ‘ instead of ” for the tags, never mind you should use script for writing service code like this.

Like
Add Comment