Skip to main content

The New Facebook Wall Publishing method Stream.publish

As recently facebook stopped supporting the feedstory publishing method to publish news on users wall and application developers from now on can't create feed templates. Facebook released a new methods to do so which are:


I figured out those new methods when I was building a new facebook application yesterday to predict who will win the soccer match between Egypt and Algeria tonight. It took me sometime to succeed in publishing the story on the wall, so I will share with you my experience and how I solved it out in Coldfusion.

As I build my applications using the work of Andrew Duckett who created the Facebook Rest Client Component, I will start from FacebookFBMLCLient.cfc file which contains the methods that communicates with facebook APIs.

As I have used one of the three methods above which sounded the best as I guess, this example will be based on stream.publish method.

The first step is to add the following method to the FacebookFBMLCLient.cfc file:

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

<cfargument name="session_key" type="string" required="true" hint="the session id of the logged in user">

<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="message">

<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 />


The second step is that you need permission from the users of the application to grant the method permission to publish on their walls, this can be done in many ways see this link, in my application I ask the permission from users when they submit the form, which I believe is the best way. So if you are using a form in your application you may get the permission to publish on users wall by By including the promptpermission attribute in the form as below:

form name="Form" promptpermission="publish_stream" action="Action.cfm" method="post">

The third step is to call the publish stream method:

cfset attachment = '{"properties":{"Votes":{"text":"Members Voted: (#eg# Votes for EGYPT)(#al# Votes for ALGERIA) (No Winner #equ#)","href":"#faceBookPath#/#appName#","rating":"rate"}},"media": [{"type":"image","src":"","href":""}]}'>

cfset action_links = '[{"text":"Make Your Prediction","href":"#faceBookPath#/#appName#"}]'>

cfset #FBMLClient.publishStream(session.fb_session_key,session.fb_uid,answer1,attachment,action_links)#>

The attachment and action_links must be in JSON format, any simple format mistake will prevent the attachment or the action_links from being published, so you should be careful.

Please note that I didn't use all options that can be published using Stream.Publish method, you may add more options to your code see the list of media and other options here.

I believe thats all what you need to publish to wall using the new facebook api's, if you need any help or have any question please add a comment to the article.


  1. Nice post. Is there any chance you can add a link to download all the files you talk about? Thanks.

  2. I will post a full tutorial with the code soon

  3. Hi,
    Though it sounds good but bit tough to make it functional.If can you please provide a sample code regarding facebook wall publishing then it would be helpful for me.

  4. I will upload a full example soon.

  5. Would really like to see the full example. Great work Mustafa! /herve

  6. Is there a way to post to many wall at the same time ?


  7. In your function call what is answer1? Also I cannot find the function 'xmlToStructParam' anywhere in FacebookRestClient.cfc - where are you getting it from? Trying to get this working. Thanks!

  8. Answer1 is a variable that is to be published on the wall, it is a string variable.

    For the xmlToStructParam it is a coldfusion function.

  9. Is there any chance you can add a link to download all the files you talk about? Thanks.

  10. Please go to this post and copy the post and save them as advised, the link is:

  11. Is there a way to post to many wall at the same time ?

  12. Yes you can, just go to this example:

    now replace the code below:


    With the code below:

    Now this loop will publish to all ur friends walls.

  13. it looks the code is not appearing in the comment contact me on mustafa at abusalah dot info

  14. Hi Mustafa, I am trying to use your code but I am getting this error:
    Variable XMLTOSTRUCTPARAM is undefined.

    I just have the .cfm file and I am calling the function and passing the parameters...what am I doing wrong?

  15. This is an old method by now, please see this post:

    This is 100% working and up to date.


Post a Comment

Popular posts from this blog

Top Google Adsense Alternatives

Google Adsense is a web tool that allows publishers in the Google Network of content sites to automatically serve text, image, video, and rich media adverts that are targeted to site content and audience. These adverts are administered, sorted, and maintained by Google, and they can generate revenue on either a per-click or per-impression basis.  Google servers advertisers using google adwords platform, while adsense is the publishers platform. Google Adsense is the top Ad Publishers platform over the web ranking number one in web advertising industry. Adsense offers contextual advertisements that covers web sites, blogs, games, videos, mobile browsing etc. What made Google Adsense no. 1 is the reliability, stability, variety of services and large number of publishers including google it self. Also google has a fair platform that detects invalid clicks so google successfully protects its advertisers and also offers its best publishers top CPC. Two reasons are behind people think

Error: Write to Disk Access Denied - Troubleshooting - BitTorrent

I have downloaded Bit Torrent software and when trying to download I got an error after few seconds saying: Error: Write to Disk Access Denied Solving this problem is so simple: Shut down BitTorrent program. Go to Start and in the small search box on top of windows start button start typing Bittorrent and the program will show, right click with the mouse on the icon and Run as Administrator. All ur problems are sorted out now and you can enjoy downloading... Good Luck.

How to Build RSS 2.0 Feed in Coldfusion 8

In this tutorial I will show some tips on how to create an RSS Feed in coldfusion by querying a Database. This example will demonstrate how to create an RSS Feed for the quote of the day. < cfquery name="qname" datasource="dbsource" maxrows="3"> SELECT PUBDATE,DESCR,FTITLE,LINK FROM wiki.url.rssfeed order by id desc </cfquery> <!--- Note here the query returns only the last three quotes and also it is sorted based on the id which is an auto increment ID.---> <cfscript> myStruct = StructNew(); = ""; myStruct.title = "Mustafa Abusalah Quote of the Day"; mystruct.description = "Quote of the Day Tutorial"; mystruct.pubDate = Now(); mystruct.version = "rss_2.0"; <!--- Now the Query columns must be mapped to the RSS columns this is done by creating a struct and mapping them to the struct variables. Please not that the fields must be written in capital letter