How do you publish to the news feed?

Dec 17, 2008 at 10:54 PM
I've been trying to use feed.publishUserAction, but I never see any stories published, even for users that have my app installed.

I'm using this code:
Dim fbm As CanvasIFrameMasterPage = CType(Master, CanvasIFrameMasterPage)
Dim templateBundleId as Long = 38155159412
Dim templateData As New Dictionary(Of String, String)
'... initialize templateData
Dim longFriends As New List(Of Long)
'... initialize longFriends
fbm.API.feed.publishUserAction(templateBundleId, templateData, longFriends, "body_general", feed.PublishedStorySize.Full)

The call returns "True", but nothing is added to the target's feed. Any ideas?

Dec 23, 2008 at 8:16 PM
What version of the framework are you using?  I'm using 2.0 (I think) and publishUserAction isn't part of the feed class.
Dec 25, 2008 at 5:14 PM
I'm using 3.5.

Intellisense works, which suggests that publishUserAction *is* part of the feed class.

If not, though, what should I be using?

Thanks for your help,

Jan 1, 2009 at 12:55 AM
I have the same issue as Michael.  The call to: Master.API.feed.publishUserAction(post1,postdict,postlist,"",storysize);
returns true, but nothing is posted.

Can anyone help with this?


Jan 1, 2009 at 10:05 PM
publishUserAction is definately part of the feed class, being new to this i havn't come to use it yet but will need to soon so an answer here will be useful for me aswell.

So i've had a quick look and it seems that template_bundle_id is bolded, doesn't this mean that it is a requirement and not optional?

I think you need to register your feed first and then call that pre registered feed using the publishUserAction function, i could be wrong but i'm sure i recal readin elsewhere that this is how it works.

I'm not sure what position that leaves us in for creating dynamic feed's though if the have to be preset?
Jan 1, 2009 at 10:54 PM

I have been trying to get this to work for a while now with no luck. After alot of reading, I registered a one line template for my FB app:

{*actor*} some random text here

I then made the call publishUserAction with the bundle_id:


MainMaster)base.Master).API.feed.publishUserAction(bundle_id, null, null, null, facebook.feed.PublishedStorySize.OneLine);


This sent the message to some of my friend's live feeds (I haven't confirmed all of them and there is a 10 limit restriction I think).

For dynamic feeds there is a function called RegisterTemplateBundle which will allow you to register your own templates.It returns a bundle_id.

I can't find a Unit Test for publishUserAction in the source code so it may not be working properly/returning correct error values.

Hope this helps

Jan 1, 2009 at 11:04 PM
Cheers JDB, i'll give that a try.
Jan 1, 2009 at 11:37 PM
What JDB has posted above works perfectly, not sure it's required but i have put it within a try/catch block so as to eliminate any problems if errors are returned when limits are exceded etc

I'll try to dynamically create some now and see how i get on :o)
Jan 2, 2009 at 11:20 PM
Edited Jan 2, 2009 at 11:21 PM
I got the publishUserAction to publish full stories using this template and code:

{*actor*} has published a full story

{*actor*} has published a full story on {*date*}



dict = new Dictionary<string, string>{{"date", "14/01/09"}};




MainMaster)base.Master).API.feed.publishUserAction(bundle_id, dict, null, null, facebook.feed.PublishedStorySize.Full);



The stories are only published to the user's wall who's using the application at the time. 

I also had to change the settings for my application to allow it to publish full stories otherwise FB will down grade it to a one liner.

The publishUserAction uses the function SendRequest which waits for a minute if the limit is reached and then tries again? Not sure why it does this as the FB doc's don't mention a minute timeout. The server response is returned as a string as oppose to re-throwing an exception. Every other error gets re-thrown.

Have a look at the Unit Test - registerTemplateBundleTest() which has a code example for registering a template at runtime.

Feb 23, 2009 at 9:31 PM
Edited Feb 23, 2009 at 9:32 PM

Geez, finding documentation on all of this has been no easy task...

So in the example above, you specified two tokens.  "Actor" and "Date".  However, you only defined one element ("date") in your generic dictionary.

So I have two questions, if anyone knows, I am greatful:

1.  did you just omit "actor" for this example assuming everyone would know to add another element to the generic dict, or is Facebook smart enough to use "actor" as some internal flag for the current user's uid?  I am assuming, actor should be added to the dict as well in order for your above example to work.

2.  If I were to do the following, would the id be returned if the template already exists (the second time I call it), or would an exception be thrown after 100 (the max limit) of templates are registered for this application?  It would not be nice at all if I had to call the register the first time, take note of the Id, and use that Id each time to return the correct template.  Hopefully FB put a unique constraint on the text for this application...

long MyTemplateID = 0;




List<string> MyOneLineStory = new List<string>();




"{*actor*} gave you a note!");




    MyTemplateID = Master.API.feed.registerTemplateBundle(MyOneLineStory,
null, null);

Thanks for any help!



Feb 24, 2009 at 6:29 AM
Hello JDB
My code is also publishing stories but it is publishing only oneline stories. Other two sizes are not possible though we specify it us the "facebook.feed.PublishedStorySize." parameter. Could you tell me what settings have you changed for the application for publishing short/full stories?
Mar 11, 2009 at 2:22 PM
Edited Mar 11, 2009 at 4:07 PM

I have the same problem as Tony! Even if i set the PublishedStorySize parameter in the publishUserAction method, facebook always publish the oneline feed.
What is the settings to change?

Thanks for your help

Update :

I solve the problem authorizing the integral wall post of my application in the wall tab of my profile application settings
Mar 12, 2009 at 4:49 AM
yes..apparently you do not have much control of the story size that gets published. It is up to the user settings to authorise this.

Has anyone manage to publish images for short story or full story templates?
Mar 12, 2009 at 3:43 PM
yes, i publish short stories but the user must athorize it OR expand the story once posted.

but I do this via my own modified 1.7 version ofthe toolki
Mar 13, 2009 at 3:35 PM
Hi all,

I have another problem with posting feeds on wall! I try to post on friends wall with the publishUserAction but i don't think it works...
So to do it I use a multiFeedStory form with an http handler which returns a json object as the wiki specs!
But the problem is that when I set the content-type of my response to "application/json", response prompt me to download the json in a file and when I don"t set the content-type,
the response show me the json object in a blanc page.

Here is my code :

the form :
<form fbtype="multiFeedStory"  action='myCallbackurl' method='POST' name='secrad'>",
              <input type='hidden' name='ecardid' value='anid' />
           <fb:multi-friend-input>  </fb:multi-friend-input>
            <input style="margin-left: 10px;" class="inputsubmit" name="buttonsend" type="Submit" value="Send Ecard" />

and the returned json object :

{"content": {"feed": {"template_id": 451944, "template_data":{"images":[{"src":"myurl","href":"otherurl"}],"comment":"coucou"}}},

I think the problem comes from the content type declaration but I'm not sure!
Any Ideas?

Thanks for your help
May 24, 2009 at 4:42 AM

Hi all, I was just reviewing this thread and have a question...

I just created my first app using the 2.0 Developer Toolkit with ASP.NET framework 3.5.

I am having the same problem mentioned above, which is I cannot seem to publish anything other than online stories using publishUserAction, regardless of whether I set PublishedStorySize to Short or Full.

Facebook's documentation says one-line stories only appear on the user's Wall, not in the News Feed on the Homepage. I'm trying to get my app to publish something that appears on the Homepage feed.

When I go to settings for my application in Profile/Applications, the only option that appears under Additional Permissions is a checkbox whether to allow my app to publish "one-line stories to my profile."

When I go into settings for other applications I have installed from other developers, which I know publish short stories that appear on the Homepage feed, that is also the only permission that appears as an option for those applications.

Is there an error in the Developer Framework 2.0 that is causing this? How can I publish a short-story using my registered template that will appear on the Homepage feed?

Here's my code:

<font size="2">

API.feed.publishUserAction([my template id here],


Nothing, Nothing, "", feed.PublishedStorySize.Short)


May 24, 2009 at 6:49 AM

OK I figured out why it wouldn't post short stories... you have to have the user grant your app extended permissions first as described at this link:


May 24, 2009 at 10:00 AM
Edited May 24, 2009 at 10:01 AM

Hi will,

the publishUserAction method is really restrictive! it allow you only to post stories on your own wall.

To publish a feed to a friend wall with any registered template you can use this code :


<form fbtype="multifeedStory" action="">           

 <fb:multi-friend-input>  </fb:multi-friend-input>

    <input type="submit" value="Publish" label="Publish" />



the handler will send this kind of response :

Note that your handler url must be in the facebook context. For example : http// not



Response.ContentType = "application/json";

Response.ContentEncoding = System.Text.Encoding.UTF8;

Response.Write("{\"content\": {\"feed\": {\"template_id\":87046436944} } , \"method\":\"multiFeedStory\", \"next\":\"\"  }");


Http response must be set to "application/json" to be caught by facebook.


Hope this will help you




May 25, 2009 at 9:14 AM



I have been struggling with this for like 3 days now. I have tried FB.Connect.showFeedDialog..but no luck

now I am trying my luck with publishUserAction..



@Willmckee, how do you grant your app extended permissions?


here's my code:


 protected void PublishUserAction_Click(object sender, EventArgs e)
            string userId;
            _fbService.ApplicationKey = FACEBOOK_APPKEY;
            _fbService.Secret = FACEBOOK_SECRET;
            string sessionKey = Session["facebook_session_key"] as String;
            userId = Session["facebook_userId"] as String;

            // When the user uses the Facebook login page, the redirect back
            // here will have the auth_token in the query params
            string authToken = Request.QueryString["auth_token"];
            // We have already established a session on behalf of this user
            if (!String.IsNullOrEmpty(sessionKey))
                _fbService.SessionKey = sessionKey;
                _fbService.uid = (long)Session["Facebook_userId"];
            // This will be executed when Facebook login redirects to our page
            else if (!String.IsNullOrEmpty(authToken))
                _fbService.ApplicationKey = FACEBOOK_APPKEY;
                _fbService.Secret = FACEBOOK_SECRET;
                Session["Facebook_session_key"] = _fbService.SessionKey;
                Session["Facebook_userId"] = _fbService.uid;
                Session["Facebook_session_expires"] = _fbService.SessionExpires;

            List<long> target_list = new List<long>();

            Dictionary<string, string> tpl_data = new Dictionary<string, string>();
            tpl_data.Add("{*actor*}", "1296968128");
            long regTemplate = 110586612436;
            _fbService.API.feed.publishUserAction(regTemplate, tpl_data, target_list, "", feed.PublishedStorySize.Full);


The code above gives me an  "Incorrect signature" error.  =((



May 26, 2009 at 2:11 AM


You have to prompt the user to give your app extended permission using one of the various methods listed on the link I posted above.

Here is the code for my most basic ASP.NET facebook app which shows the friend count and the user's profile image.

You see in the ASPX the link I put at the top to appear... when the user clicks this link, it prompts them to give your app the extended permission(s) you specify in the "perms" attribute.


<%@ Page Language="VB" Debug="true" AutoEventWireup="true" CodeFile="Default.aspx.vb"
    Inherits="_Default" %>

<form id="form1" runat="server">
<fb:prompt-permission perms="publish_stream">
Grant permission for status updates
    <%= API.users.getInfo().name %>
    <br />
    <br />
    I see you have
    friends, wow.
    <br />
    <br />
    <img src='<%=API.users.getInfo().pic%>' />
    <br />
    <br />
    <asp:scriptmanager id="ScriptManager1" runat="server" />

In the codebehind file you must make sure your page inherits from the Toolkit class, like this:

Partial Class _Default Inherits facebook.web.CanvasFBMLBasePage

My page uses Partial classes b/c I am using an AJAX-enabled ASP.NET site, which is also why there is a ScriptManager in the ASPX.



May 26, 2009 at 4:39 AM

Thanks for your quick reply willmckee!

I just have a problem, I am using IFRame and I do not know how to use this using IFrame :( In face I do not know how to use other FBML on an IFrame.

<fb:prompt-permission perms="publish_stream">
Grant permission for status updates

Anyone please? I have a few more days to finish this project and I haven't accomplish anything stunning yet..... :((

May 26, 2009 at 5:45 AM


did you look at the link i posted above? it lists other methods you can use and says:

"By calling FB.Connect.showPermissionDialog, for use with IFrame applications and Facebook Connect sites. "



May 27, 2009 at 3:40 AM

Oooohhh... sorry, I did not see that. Thanks man! I got the permission pop up. Now I have to know the Connect settings.


Also for my other problem , "The code above gives me an  "Incorrect signature" error.  " -- I added this line:

_fbService.API.IsDesktopApplication = false; 

and that error was gone.

Jun 4, 2009 at 1:33 PM
Edited Jun 4, 2009 at 1:34 PM

Hi willmckee,

i have given extended permissions as (update status) and when i try to publish to friends news feed it is getting displayed in my profile but not in news feed.  It was working fine untill a week before. Can you please tell me the reason for it. Is it due to any changes in api?


Jun 4, 2009 at 3:57 PM

Hi bsk,

this is normal because the PublishUserAction method allow you only to post on your own wall!! I post above the method to use to post to your friend's wall. Just scroll up and read it :)


Jun 5, 2009 at 5:29 AM

Hi Lolo,

Thank you for the reply :) . i will try with the code in your older posts and check it.


Jun 8, 2009 at 2:36 AM

Hi Lolo,

Is there a way to use <fb:multi-friend-input> on an IFrame?

Thank you,


Jun 8, 2009 at 8:17 AM
Edited Jun 8, 2009 at 8:18 AM

hi debsky,


I never used IFrame in my facebook developpement so i can't tell you a way to use this with iframe.
But I have an other way to publish on friends wall using javascript.


            var user_message_prompt = "My popup headder";

            var user_message = { value: "hello world" };

            var template_bundle_id = 67262683379; <-- facebook template uid

            var template_data = {

                "comment": document.getElementById("comment").getValue(),

                "images": [{

                    "src": document.getElementById("ecardurl").getValue(),

                    "href": document.getElementById("cmaurl").getValue()}]

                }; <-- Data attached with your template


                var body_general = <%= string.Format("\"Publié par <a href='{0}'>CMonAnniversaire</a>\"",CMAFacebook.Core.Helpers.CallbackUrl) %>;

                var target_ids = document.getElementById("targetid").getValue();


                var continuation = function() {

                    new Dialog(Dialog.DIALOG_POP).showMessage("C Mon Anniversaire ", "L'ecard a été envoyé avec succès !!", button_confirm = 'Okay');


                //Prompt the user to publish the message

                Facebook.showFeedDialog(template_bundle_id, template_data, body_general, target_ids, continuation, user_message_prompt, user_message);

                return false;


You just have to call this javascript method at the submit of your form


Hope that it helps




Jun 9, 2009 at 6:32 PM

I've been unable to get PublishUserAction to post to friends' news feed. I'm using iFrame and not sure if the javascript solution would work. Any help would be appreciated!

By the way- some people may be having a problem posting full stories; I think this is because facebook got rid of full--they're just doing small and one line, I think.

Jun 9, 2009 at 7:06 PM

to do fb:multi-friend-input in an IFRAme you'll need to use XFBML and fb:serverfbml.


Jun 23, 2009 at 4:12 AM

Could anyone post the entire javascript for a popup dialog box (showFeedDialog I think) to be placed in an iframe application to post news feeds to friends of a user?

Any help is much appreciated!

Jul 7, 2009 at 9:45 PM

I am also in desperate need of a way to publish to news feeds from an ASP.NET/C# IFrame application.  I don't need to publish to friends' feeds, just to the user's feed.  My application is a quiz and I want users to be able to publish their scores when they're done.  I've read article after article and thread after thread and I just can't seem to get it to work! ARGH!

Jul 9, 2009 at 2:25 PM

@JeTmAn - by far the easiest way to post to the feed is stream.publish (which was implemented)

@joejoejoejoe47 - we are working on a new IFrame sample as part of version 3.0 which will try to demonstrate using XFBML and FBJS from an IFRAME.  Should be available soon.

Jul 9, 2009 at 6:13 PM

stream.publish is part of the Facebook Connect library, right?  I'm able to get notifications working through codebehind as well as the publishUserAction method, which pops up a message saying that my message has been posted to the user's feed, but then I can't find it in the actual feed.  However, I've noticed that it seems that FB Connect methods are only supposed to be used in javascript.  Here's what I've got for my attempt to use showFeedDialog:

<script type="text/javascript">
    var api_key = '<%=ConfigurationSettings.AppSettings["APIKey"] %>';
    var template_data = "";
    var callback = "";
    var body_general = "test";
    var channel_path = "xd_receiver.htm";
    var user_message_prompt = "What do you think of this subject?";
    var ok;
    //var user_message = {"value": "write your review here"};

    function() {
        FB.Facebook.init(api_key, channel_path, null);
                    ok = FB.Connect.showFeedDialog(83540279572, template_data, 1572789807, body_general, null, 0, callback, user_message_prompt);



I thought this script would run automatically when the page loads and pop up the dialog asking for permissions to publish to the user's feed.  I've got my whole app working as far as the actual quiz components and the piece for sending a link to the quiz to friends, but I just need to get it to ask if you want to publish to your feed at the very end.  For whatever reason, the stuff I've tried just doesn't do anything and I can't figure out how to get it to work.  Thanks for your input.