Skip to content

Instantly share code, notes, and snippets.

@mbejda
Created December 14, 2015 19:25
Show Gist options
  • Select an option

  • Save mbejda/47bd4d1260869d477db6 to your computer and use it in GitHub Desktop.

Select an option

Save mbejda/47bd4d1260869d477db6 to your computer and use it in GitHub Desktop.
Coldfusion: Publishing Photo To Facebook
<cfset accessToken = "#Attributes.accessToken#">
<cfset sourcePath = "#Attributes.sourcePath#">
<cfset pageId = "#Attributes.pageId#">
<cfset text = "#Attributes.text#">
<cfset facebookGraphAPIPage = createObject('component','/lib/facebook-cf-sdk-master/sdk/FacebookGraphApi').init(accessToken=accessToken,appId= request.facebookAppId)>
<cfimage
name="temp"
action="read"
source="#ExpandPath( './assets/images/placeholder/#sourcePath#' )#"
/>
<cfset attr = StructNew()>
<cfset attr.size = 40>
<cfset attr.style = "bold">
<cfset ImageSetDrawingColor(temp,"Black")>
<cfset ImageDrawText(temp,text,50,350,attr)>
<cfset ImageDrawText(temp,text,50,475,attr)>
<cfxml variable="imageXml">
<cfimage
action="writetobrowser"
source="#temp#"
/>
</cfxml>
<cfset results = facebookGraphAPIPage.publishPhoto(profileId=pageId,sourcePath="http://#cgi.HTTP_HOST##imageXml.xmlRoot.xmlAttributes.src#")>
<cfcontent type="application/json">
<cfoutput>
#serializeJSON(results,true)#
</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment