publishTemplatizedAction

Oct 2, 2008 at 7:17 PM
Edited Oct 2, 2008 at 8:46 PM
I'm able to access user information, but unable to publish anything in a feed.

This is what I have

protected void btnGo_Click(object sender, EventArgs e)
    {
        visitorInfo = this.API.users.getInfo(this.API.uid);
        this.API.feed.publishTemplatizedAction("hi", null, "yo", null, null, null, null, null);
    }

I get:
 facebook.Utility.FacebookException: Invalid parameter
with nothing else
Does anyone have any suggestions?

Oct 2, 2008 at 8:46 PM
I don't know why but this seems to work:
this.API.feed.publishTemplatizedAction("{actor} is", null, "arg", null, null, 0, null, null);

maybe it'll help others
Oct 2, 2008 at 10:50 PM
Edited Oct 2, 2008 at 10:52 PM
You need "{actor}" in the template but that isn't required in your dictionary as FB knows what to do with it (and a few other keywords).

Here's my call slightly modified ;)

// Set up the body text
Dictionary<string, string> bodyDictionary = new Dictionary<string, string>();
bodyDictionary.Add("trouser_style", "parachute pants");

// Add an image to the details
Collection<feed_image> feedImages = new Collection<feed_image>();
feedImages.Add(new feed_image("http://blah.com/fullImageLocation.png"), "http://blah.com/thisIsWhereToClickThroughTo.aspx");

// Publish this biznatch
this.Master.API.feed.publishTemplatizedAction("{actor} did something",
                    null,
                    "{actor} loves to wear {trouser_style}.",
                    bodyDictionary,
                    "<br/>Thanks for reading my footer",
                    0,
                    feedImages,
                    null);

You might want to wrap the publish call in a try/catch because it'll throw an exception on things like: A particular users's gone over their daily limit for your app.  It can't find your images (happens to me if I've uploaded new images, seems to take FB a while to find them).

Note, however, that this is the old way of publishing stories.  I'm still waiting for publishUserAction which uses the new Facebook "3 sizes" news format (one line, short, full).
Oct 3, 2008 at 8:36 PM
mrated,

All you need to do is register your templates at

http://developers.new.facebook.com/tools.php?feed

you have to preview them to save them, which means you need to modify the data in the sample template data block.

then you publish them with
_fbService.feed.publishUserAction
passing in the template id you got when you saved the templates. I published all code to do it in this post. http://www.codeplex.com/FacebookToolkit/Thread/View.aspx?ThreadId=36284. The difference is that you no longer need to publish your templates in code as I stated in this post.
Oct 3, 2008 at 10:18 PM
Edited Oct 3, 2008 at 10:19 PM
Thanks cartango but I'd rather wait for a "proper" release of the toolkit.  Surely we're due for one soon seeing as the last one was August 8th?

Unless of course you'd like to put your compiled DLLs somewhere we can grab 'em! ;)
Oct 15, 2008 at 11:29 AM
Hi guys! Im trying to post the own news to news feed and faced the same problems as you wrote about in all your posts.
Could you please answer the following questions?
1. I have the following implementation of in the API version i downloaded:
        public bool publishTemplatizedAction(string title_template, Dictionary<string, string> title_data,
                                               string body_template, Dictionary<string, string> body_data,
                                               string body_general, int page_actor_id,
                                               Collection<feed_image> images, Collection<string> target_ids)
        {
            var parameterList = new Dictionary<string, string>{{"method", "facebook.feed.publishTemplatizedAction"}};
            _api.AddRequiredParameter(parameterList, "title_template", title_template);
            _api.AddOptionalParameter(parameterList, "page_actor_id", page_actor_id);
            _api.AddJSONAssociativeArray(parameterList, "title_data", title_data);
            _api.AddJSONAssociativeArray(parameterList, "body_data", body_data);
            _api.AddOptionalParameter(parameterList, "body_template", body_template);
            _api.AddOptionalParameter(parameterList, "body_general", body_general);
            _api.AddCollection(parameterList, "target_ids", target_ids);
            AddFeedImages(parameterList, images);

            var response = _api.SendRequest(parameterList);
            return string.IsNullOrEmpty(response) || feed_publishTemplatizedAction_response.Parse(response).TypedValue;
        }
Can i use it? Or should i get this method implementation from that "http://www.codeplex.com/FacebookToolkit/Thread/View.aspx?ThreadId=34590" thread??

2. Also, i tried to use the following part of the code from that thread:
// Set up the body text
Dictionary<string, string> bodyDictionary = new Dictionary<string, string>();
bodyDictionary.Add("trouser_style", "parachute pants");

// Add an image to the details
Collection<feed_image> feedImages = new Collection<feed_image>();
feedImages.Add(new feed_image("http://blah.com/fullImageLocation.png"), "http://blah.com/thisIsWhereToClickThroughTo.aspx");

// Publish this biznatch
this.Master.API.feed.publishTemplatizedAction("{actor} did something",
                    null,
                    "{actor} loves to wear {trouser_style}.",
                    bodyDictionary,
                    "<br/>Thanks for reading my footer",
                    0,
                    feedImages,
                    null);

But it doesnt work for me. Im getting the following exception:

"{facebook.Utility.FacebookException: This method can only be used to publish Mini-Feed stories to Facebook Pages. Its use for posting feed stories to user pages has been deprecated.  at facebook.API.ErrorCheck(String xml) ........"

So may be i need to use the sample from that tread "http://www.codeplex.com/FacebookToolkit/Thread/View.aspx?ThreadId=36284" instead of above one?

Also could you please share the working sample/solution of publishTemplatizedAction? It would be great!
Thanks in advance.



Oct 15, 2008 at 11:33 AM
Facebook deprecated this method about 5 hours ago... Once again working with their API is like pushing water uphill.

We need the publishUserAction() method in the toolkit and while there are mentions of people with solutions nobody seems willing to upload a DLL or update the toolkit proper.
Oct 15, 2008 at 4:24 PM
Also, you didnt answer if my way was a right one...

Why did they depricate this method? Anybody know the answer? Also, where could we read the news around the FB API development?
Oct 15, 2008 at 9:04 PM
That's rough... I think I just wasted 3 days
I'll be looking out for publishUserAction() . Any other ways to post feeds to users or friends?
Oct 15, 2008 at 9:47 PM
Edited Oct 15, 2008 at 9:49 PM
evrp: The method was deprecated as they want you to use the publishUserAction which has the three different sizes (set by the user).  One line, Short or Full...

joejoejoejoe47 (that's a lot of joes!): One method I wasted a few hours on was the FBJS in an IFrame method.  Read through this and see if you can get it to work.  I've never been able to get their script-in-an-iframe stuff working. 

New Feed Form: http://wiki.developers.facebook.com/index.php/New_Design_Feed_Forms
FBJS Method: http://wiki.developers.facebook.com/index.php/Creating_a_Popup_Dialog_in_an_IFrame