Feed Publishing

The .NET Facebook API Client makes working with Feed templates stupidly easy by allowing you to define your templates in an XML file with a friendly name, and then automatically registering the templates for you when your application initializes.

Configuration

  • Create an xml file with with your templates using the following format:
<feedTemplates>
  <feedTemplate name="testStory">
    <oneLineTemplate>{*actor*} is kicking butt with the new .NET API Client.</oneLineTemplate>
    <shortStory>
      <title>{*actor*} is kicking butt with the new .NET API Client.</title>
      <body>The .NET API client makes posting stories like this ridiculously easy!</body>
    </shortStory>
    <actionLink>
      <text>.NET API Client</text>
      <href>http://apps.facebook.com/dotnetapi</href>
    </actionLink>
  </feedTemplate>
  <feedTemplate name="DemoStory">
    <oneLineTemplate>{*actor*} is checking out the new .NET Facebook API Client.</oneLineTemplate>
    <shortStory>
      <title>{*actor*} is checking out the new .NET Facebook API Client.</title>
      <body>There's a new cowboy in Facebook API-towne! Yeehaw!</body>
    </shortStory>
    <actionLink>
      <text>.NET Facebook API Client</text>
      <href>http://apps.facebook.com/dotnetapi</href>
    </actionLink>
  </feedTemplate>
</feedTemplates>
It is recommended that you save the file with the .config extension so that the file cannot be downloaded.
  • Add the feedTemplateConfigSource attribute to the <facebook> configuration element in web.config (see Getting Started for more information) with the relative path of the saved file:
<facebook feedTemplateConfigSource="web.facebook.templates.config">

Publishing

Note: There are currently only helpers for ASP.NET MVC applications. ASP.NET server controls are planned to provide similar functionality for a future release for WebForms applications.

FBML Applications

  • Render the feed form using the FbmlHelper.FeedForm method:
<%= Fbml.FeedForm("DemoStory", "Publish") %>
When the user clicks "publish", the FeedController will automatically handle the resulting POST from Facebook for you.

IFrame Applications

  • Render a button using the FbIFrameHelper.FeedForm method:
<%= FbIFrame.FeedForm("DemoStory", "Publish") %>
Note: additional fields are not supported at this time.

Last edited Apr 13, 2009 at 6:42 PM by DanielSchaffer, version 3

Comments

petegreg Sep 4, 2009 at 3:57 AM 
Can you add some samples for usage of the fieldName parameters please?
I'm trying to pre-populate the user_message with some dynamic content.

Not sure how this line in FBIFrameHelper should behave "form.Append(String.Format("<input type='text' id='{0}' value='{0} data')></input><br/>",fieldName));"
Is value='{0} data' correct?