Coldfusion: 5 Simple Steps to Publish on Facebook Wall using Coldfusion

There are two different Libraries available for Coldfusion to publish on facebook.

According to facebook Wiki posting on a wall is very confusing and very difficult to write a program to publish on a wall.

I spent around 2 weeks reading many articles and many documents, Wiki on facebook but in vein and tried many ways and finally I got one workable model. Below are 5 simple steps to publish on a Facebook wall.

Step1: Login to Facebook

First login to Facebook and goto the url then

Click on “+ Set Up New Application” button to start creating the application as shown below.

start application

Provide the application name, click agree for facebook terms and click on “Create Application” button.

Fill in application Name

create app step1

Now Application is created for you. Just copy the Application API Key, Application Secret and Application ID details which will be used to write the application code.

application page

Now goto Canvas link and enter any url.


Next goto Connect URL link and enter the same url.


Then click on Save. That’s it we have created a facebook application with an Iframe.

Now Copy Application API Key, Application Secret and Application ID details which will be used to write the application code.

For use with FBML

  • Dominic Watson has created a starter template specifically for users wanting to use FBML. You can download it from RiaForge here:

For use with iFrames

Step2: Generate One Time Session key

How to generate One Time Session key:

Run below URL to get temporary token for the selected user by logging into Facebook.

Note: Please replace “API_KEY” with your application API key from above page.

Then we will get a temporary token key.


generatemylogin info


This is one time token key that we can use to generate a permanent session key. Careful! Don’t try to execute this programs many times

Step3: Generate one time session key

Below is the sample code to generate one time session key.

For example, the full URL for logging in a user could be:,publish_stream,offline_access

If the user is redirected to the URL specified by the next parameter, then Facebook grants your application a session. This session is appended to the URL as a JSON-decodable object of the form:

&session={“session_key”:”SESSIONKEY”, “uid”:USERID, “expires”:0 || UNIXTIME, “secret”:”SESSIONSECRET”}

In continuing with the above example, the redirect for a successful login would be:

If the user grants your application the offline_access extended permission, 0 gets returned for expires and the session never expires unless the user removes the application. In this case, you should store the session key so the user doesn’t have to log in the next time he or she launches your application.

Once the browser has been redirected successfully and you have your session information, you should automatically close the browser window.
Note: The above code will execute only once. We should note down the above session key, This will be used to auto login into the application.

If you don’t save these session key values you should generate other token key to create one time session key.

Step4: Setting Permission for wall

Giving Permission to your application to publish on facebook wall. To give permission just replace the your API key in below URL and execute in browser.,publish_stream,offline_access

Then you must see the below 3 Screens

If you don’t see the below then your call back URL or Canvas URL must be incorrect, please check again your application settings and execute the URL again.



Then on final page, you will see a success message. That’s it you have given permission for read_stream,publish_stream and offline_access.

Step5: Publishing the message with Image and link on Facebook Wall using ColdFusion

Publishing a Post With Image and Action Link using Coldfusion

ColdFusion Code to create facebook object with onetime session key and publishing the message on Facebook Wall.

<cffunction name="publishStream" access="public" output="false" returntype="any" hint="Publish Steven on Facebook">

<cfargument name="session_key" type="string" required="true" hint="SESSION_KEY">

<cfargument name="to_ids" type="string" required="true" hint="ids of all the friends user has chosen">

<cfargument name="message" type="string" required="true" hint="publish steven on facebook">

<cfargument name="attachment" type="Any" required="true" hint="JSON Object">

<cfargument name="action_links" type="Any" required="true" hint="JSON Object">

<!--- local vars --->

<cfset var params = StructNew() />

<!--- the api call --->

<cfset params["session_key"] = arguments.session_key />

<!--- <cfset params["uids"] = arguments.to_ids />--->

<cfset params["message"] = arguments.message />

<cfset params["attachment"] = arguments.attachment />

<cfset params["action_links"] = arguments.action_links />

<!--- Invoke stream.publish API --->

<cfset sendNoteVar = xmlToStructParam('',params) />

<cfreturn sendNoteVar />


In the above code there is not necessary to have the action link and attachment URL. If you would like to only publish any image then you need to give that two params.

Now you will see the post on wall Great.

published on facebook

So thrilling isn’t we can also publish photos videos on wall.

More information on ColdFusion can be found here

have a great day

— Steven

Please don’t copy this content to any site. This is fully protected by TheUnical Technologies