The news feeds done!

Jul 17, 2008 at 5:38 PM
Edited Jul 17, 2008 at 7:35 PM

Hello everybody,

 I have been working on the new api changes( specially the feeds changes). I got them all working except that my code allows adding one image only to the feed.

Images appear only in short line stories. If you want images to appear in full stories, use <img> tag in the full story data.

You can use it until version 2.0 is launched.

You need to copy the code to the source code (FacebookAPI.cs) and compile.

Enjoy.

----------------------------------------------------------------------------------------------------------

 

   public string RegisterTemplateBundle(string one_line_story_templates, string short_story_template_title, string short_story_template_body, string full_story_template_title,  string full_story_template_body)

        {

            Dictionary<string, string> parameterList = new Dictionary<string, string>();

            parameterList.Add("method", "Feed.registerTemplateBundle");

 

            parameterList.Add("one_line_story_templates", one_line_story_templates);// should be written like this:   string one_line_story_templates = "[\"{*actor*} has been playing.\"]";

 

 

 

            Dictionary<string, string> short_story_templates = new Dictionary<string, string>();

 

 

 

            short_story_templates.Add("template_title", short_story_template_title);// should be written like this: string short_story_template_title="{*actor*} has been playing !"

 

            short_story_templates.Add("template_body", short_story_template_body);

 

 

            AddParameterJSON(parameterList, "short_story_templates", short_story_templates);

 

            Dictionary<string, string> full_story_template = new Dictionary<string, string>();

         

 

 

            full_story_template.Add("template_title", full_story_template_title);

            full_story_template.Add("template_body", full_story_template_body);

 

            AddParameterJSON(parameterList, "full_story_template", full_story_template);

 

 

            return GetSingleNode(ExecuteApiCallString(parameterList, false), "feed_registerTemplateBundle_response");

        }

----------------------------------------------------------------------------------------------------------

 

 

  

 

string

 

ExecuteApiCallString(IDictionary<string, string> parameterDictionary, bool useSession)

 

{

 

if (useSession)

 

{

parameterDictionary.Add(

"session_key", SessionKey);

 

}

 

bool useNew = false;

 

 

 

 

if (parameterDictionary["method"] == "Feed.registerTemplateBundle")

 

useNew =

true;

 

 

else if (parameterDictionary["method"] == "Feed.publishUserAction")

 

 

useNew =

true;

 

 

 

 

 

 

 

 

string requestUrl = "";

 

 

 

if (useNew)

 

requestUrl = GetRequestUrlNew(parameterDictionary[

"method"] == "auth.getSession");

 

 

else

 

 

 

 

requestUrl = GetRequestUrl(parameterDictionary[

"method"] == "auth.getSession");

 

 

string parameters = CreateHTTPParameterList(parameterDictionary);

 

 

return GetQueryResponse(requestUrl, parameters);

 

}

 

 

----------------------------------------------------------------------------------------------------------

 

 

  static string GetRequestUrlNew(bool useSSL)

        {

 

            return useSSL ? "http://api.new.facebook.com/bestserver.php".Replace("http", "https") : "http://api.new.facebook.com/bestserver.php";

 

        }

----------------------------------------------------------------------------------------------------------

 

 

 

    public string PublishUserAction(string template_bundle_id, Dictionary<string, string> template_data, Dictionary<string, string> imageDetails,

            string body_general, string target_ids)

        {

            Dictionary<string, string> parameterList = new Dictionary<string, string>();

            parameterList.Add("method", "Feed.publishUserAction");

            parameterList.Add("template_bundle_id", template_bundle_id);

 

            AddParameterJSONImages(template_data, "images", imageDetails);// only one image

 

            // should be like this:   imageDetails.Add("src",image link);

 

            //                        imageDetails.Add("href", link);

 

 

            parameterList.Add("template_data", ToJsonAssociativeArrayTemplateData(template_data));

 

            parameterList.Add("body_general", body_general);

            parameterList.Add("target_ids", target_ids); // comma separted

 

 

 

 

            return GetSingleNode(ExecuteApiCallString(parameterList, true), "feed_publishUserAction_response");

        }

----------------------------------------------------------------------------------------------------------

 

 

 static string ToJsonAssociativeArrayTemplateData(Dictionary<string, string> paramDictionary)

        {

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

 

            foreach (KeyValuePair<string, string> pair in paramDictionary)

            {

                if (pair.Key != "images")

                {

                    nameValuePairs.Add("\"" + pair.Key + "\":\"" + pair.Value + "\"");

                }

                else

 

                {

                    nameValuePairs.Add("\"" + pair.Key + "\":" + pair.Value);

 

                }

            }

 

            return "{" + string.Join(",", nameValuePairs.ToArray()) + "}";

        }

 

----------------------------------------------------------------------------------------------------------

 

        private void AddParameterJSONTemplateData(IDictionary<string, string> dict, string key, Dictionary<string, string> value)

        {

            if (value != null && value.Count > 0)

            {

                dict.Add(key, ToJsonAssociativeArrayTemplateData(value));

            }

        }

 

----------------------------------------------------------------------------------------------------------

 

        static string ToJsonAssociativeArrayImages(Dictionary<string, string> paramDictionary)

        {

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

 

            foreach (KeyValuePair<string, string> pair in paramDictionary)

            {

                nameValuePairs.Add("\"" + pair.Key + "\":\"" + pair.Value + "\"");

            }

 

            return "[{" + string.Join(",", nameValuePairs.ToArray()) + "}]";

        }

 

 

 

 

----------------------------------------------------------------------------------------------------------

 

        private void AddParameterJSONImages(IDictionary<string, string> dict, string key, Dictionary<string, string> value)

        {

            if (value != null && value.Count > 0)

            {

                dict.Add(key, ToJsonAssociativeArrayImages(value));

            }

        }

 

 

 

 

 

 

 

 

 

 

Jul 28, 2008 at 12:13 AM
In the RegisterTemplateBundle method change the line: 
return GetSingleNode(ExecuteApiCallString(parameterList, false), "feed_registerTemplateBundle_response");
to:
return GetSingleNode(ExecuteApiCallString(parameterList, false), "Feed_registerTemplateBundle_response");

....the literal value to retrieve the node in the XML in the GetSingleNode method (in the response from FB) is wrong
Jul 28, 2008 at 12:42 AM
I knew about that. But as I have not seen any respond or reply, I neglected it.

:)
Jul 28, 2008 at 5:51 AM
gotcha. Would you be able to post an example of the incoming parameters to both the RegisterTemplateBundle and PublishTemplateBundle methods.I have the RegisterTemplateBundle method working, since I'm getting a templateId back from FB, but I can't seem to get the template_data array lined up with the template that created (i.e., apparently can't get the token values to cover the token placeholders). I tried to piece everything together based on your hints in the comments, but had no luck, or it might just be a simple syntax issue.
Thanks!
Jul 28, 2008 at 1:07 PM

 

This is for RegisterTemplateBundle:

 

 

 


string

 

one_line_story_templates = "[\"{*actor*} has been <a href='http://www.facebook.com/apps/application.php?id=xxx>Playing!</a>\"]";

 

 

string short_story_template_title = "{*actor*} has been <a href='http://www.facebook.com/apps/application.php?id=xxx>Playing!</a>";

 

 

string short_story_template_body = "{*actor*} has just <b><a href='http://www.facebook.com/apps/application.php?id=xxx>Played</a></b>  with<fb:name uid='{*PlayerID*}' capitalize='true' useyou='true' /> Via{*GameName*}";

 

================================================================================================================================= 

This is for PublishUserAction

 

 

 

 


string GameName="something";
Dictionary
<string, string> template_data = new Dictionary<string, string>();

 

 

Dictionary<string, string> imageDetails = new Dictionary<string, string>();

 

imageDetails.Add(

"src", "blah blah");

 

imageDetails.Add(

"href", "blah blah");

 

template_data.Add(

"GameName"GameName);

 

 

 

 

template_data.Add(

"PlayerID"PlayerID);

 

 

this.FacebookAPI.PublishUserAction("xxxxxx", template_data, imageDetails, ""PlayerID);

 

 

 

 

 

 

Jul 28, 2008 at 6:01 PM

I'm still receiving a "The template data provided doesn't cover the entire token set needed to publish the story" exception.

Here's my code to register and publish:

 

string one_line_story_templates = "[\"{*actor*} has been <a href='http://www.facebook.com/apps/application.php?id=xxx>Playing Poker!</a>\"]";
string short_story_template_title = "{*actor*} has been <a href='http://www.facebook.com/apps/application.php?id=xxx>Playing Poker!</a>";
string short_story_template_body = "{*actor*} has just <b><a href='http://www.facebook.com/apps/application.php?id=xxx>Played</a></b> with<fb:name uid='{*PlayerID*}' capitalize='true' useyou='true' /> Via{*GameName*}";
string full_story_template_title = "{*actor*} has been <a href='http://www.facebook.com/apps/application.php?id=xxx>Playing Poker!</a>";
string full_story_template_body = "{*actor*} has just <b><a href='http://www.facebook.com/apps/application.php?id=xxx>Played</a></b> with<fb:name uid='{*PlayerID*}' capitalize='true' useyou='true' /> Via{*GameName*}";

string templateBundleId = m_fbService.RegisterTemplateBundle(one_line_story_templates, short_story_template_title, short_story_template_body, full_story_template_title, full_story_template_body);

 

 

string GameName = "Poker";
string PlayerID = "Chris Moneymaker";

 

System.Collections.Generic.

Dictionary<string, string> template_data = new System.Collections.Generic.Dictionary<string, string>();
System.Collections.Generic.
Dictionary<string, string> imageDetails = new System.Collections.Generic.Dictionary<string, string>();

 

imageDetails.Add(

"src" "http://www.yahoo.com/images/test.jpg");
imageDetails.Add(
"href", "http://www.yahoo.com");
template_data.Add(
"GameName", GameName);
template_data.Add(
"PlayerID", PlayerID);
m_fbService.PublishUserAction(templateBundleId, template_data, imageDetails,
"", PlayerID);


Any idea why I'm getting that error yet?
Thanks again.

 

Jul 28, 2008 at 11:34 PM
This is wierd. Have you checked that you are using the correct bundle ID??
Jul 29, 2008 at 12:46 AM
Edited Jul 29, 2008 at 1:42 AM
Yes, I'm definitely using the correct templateId. Also, In a typical scenario if I was to get this working correctly, when should the RegisterTemplateBundle method be called? Each time the app is started, each time a notification is sent by a user? Is there a way to 'unregister' the template bundle or manage them? Those template_data values that are passed in, that's the correct syntax? they don't need quotes or some other delimiting symbol surrounding them in the actual string?
Jul 29, 2008 at 11:42 PM
In a typical scenario if I was to get this working correctly, when should the RegisterTemplateBundle method be called?

You should register the bundle only once. Then, you store the ID and start using it for the whole app.

You can use as much as you want.



Each time the app is started, each time a notification is sent by a user?

No,No.



Is there a way to 'unregister' the template bundle or manage them? 

You can unregister the bundle. See this http://wiki.developers.facebook.com/index.php/Feed.deactivateTemplateBundleByID



Those template_data values that are passed in, that's the correct syntax? 

Yep.



they don't need quotes or some other delimiting symbol surrounding them in the actual string?

They should be like this {*Mido*}



Jul 30, 2008 at 12:51 AM
The RegisterTemplateBundle method doesn't allow one to pass an array of short story titles and bodies, which Facebook permits/encourages.  Also, it would be cool if the caller didn't have to worry about json encoding the template strings.  That should be handled by the method.
http://wiki.developers.facebook.com/index.php/Feed.registerTemplateBundle
Jul 30, 2008 at 9:31 AM

I dont understand your point TheRealMrT, if you have any useful code, please post it. Otherwise, dont confuse us please.

 

:)

 

Jul 30, 2008 at 11:27 AM
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="ProgId" content="Word.Document"> <meta name="Generator" content="Microsoft Word 12"> <meta name="Originator" content="Microsoft Word 12"> <link rel="File-List" href="file:///C:%5CDOCUME%7E1%5Ckjohnson.ACA%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"> <link rel="themeData" href="file:///C:%5CDOCUME%7E1%5Ckjohnson.ACA%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"> <link rel="colorSchemeMapping" href="file:///C:%5CDOCUME%7E1%5Ckjohnson.ACA%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>EN-US</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:SplitPgBreakAndParaMark/> <w:DontVertAlignCellWithSp/> <w:DontBreakConstrainedForcedTables/> <w:DontVertAlignInTxbx/> <w:Word11KerningPairs/> <w:CachedColBalance/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathPr> <m:mathFont m:val="Cambria Math"/> <m:brkBin m:val="before"/> <m:brkBinSub m:val="--"/> <m:smallFrac m:val="off"/> <m:dispDef/> <m:lMargin m:val="0"/> <m:rMargin m:val="0"/> <m:defJc m:val="centerGroup"/> <m:wrapIndent m:val="1440"/> <m:intLim m:val="subSup"/> <m:naryLim m:val="undOvr"/> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true" DefSemiHidden="true" DefQFormat="false" DefPriority="99" LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Normal"/> <w:LsdException Locked="false" Priority="9" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="heading 1"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/> <w:LsdException Locked="false" Priority="39" Name="toc 1"/> <w:LsdException Locked="false" Priority="39" Name="toc 2"/> <w:LsdException Locked="false" Priority="39" Name="toc 3"/> <w:LsdException Locked="false" Priority="39" Name="toc 4"/> <w:LsdException Locked="false" Priority="39" Name="toc 5"/> <w:LsdException Locked="false" Priority="39" Name="toc 6"/> <w:LsdException Locked="false" Priority="39" Name="toc 7"/> <w:LsdException Locked="false" Priority="39" Name="toc 8"/> <w:LsdException Locked="false" Priority="39" Name="toc 9"/> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/> <w:LsdException Locked="false" Priority="10" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Title"/> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/> <w:LsdException Locked="false" Priority="11" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/> <w:LsdException Locked="false" Priority="22" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Strong"/> <w:LsdException Locked="false" Priority="20" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/> <w:LsdException Locked="false" Priority="59" SemiHidden="false" UnhideWhenUsed="false" Name="Table Grid"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/> <w:LsdException Locked="false" Priority="1" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 1"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 1"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 1"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/> <w:LsdException Locked="false" Priority="34" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/> <w:LsdException Locked="false" Priority="29" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Quote"/> <w:LsdException Locked="false" Priority="30" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 1"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 1"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 2"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 2"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 2"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 2"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 2"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 3"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 3"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 3"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 3"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 3"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 4"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 4"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 4"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 4"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 4"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 5"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 5"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 5"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 5"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 5"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 6"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 6"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 6"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 6"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 6"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/> <w:LsdException Locked="false" Priority="19" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/> <w:LsdException Locked="false" Priority="21" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/> <w:LsdException Locked="false" Priority="31" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/> <w:LsdException Locked="false" Priority="32" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/> <w:LsdException Locked="false" Priority="33" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Book Title"/> <w:LsdException Locked="false" Priority="37" Name="Bibliography"/> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/> </w:LatentStyles> </xml><![endif]--> <style> <!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} a:link, span.MsoHyperlink {mso-style-noshow:yes; mso-style-priority:99; color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {mso-style-noshow:yes; mso-style-priority:99; color:purple; mso-themecolor:followedhyperlink; text-decoration:underline; text-underline:single;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style> <!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;} </style> <![endif]-->

I agree with midowazzan, the conversations here are impossible to follow.  It is quite difficult to learn the status of any forthcoming releases of the toolkit.

Jul 30, 2008 at 11:28 AM
Sorry for the MS Word mess in my post...
Jul 30, 2008 at 6:43 PM
@midowazzan -- Sorry, that didn't come through clearly.  What I was trying to point out was that the function RegisterTemplateBundle should let the caller pass arrays of short_title_templates and short_body_templates.  Currently, you can only pass 1 string each. 

From the Facebook docs:
http://wiki.developers.facebook.com/index.php/Feed.registerTemplateBundle

> short_story_templates  -- A JSON-encoded array of dictionaries, where each dictionary represents a short story template. Each dictionary should include two fields: template_title, which should be mapped to the FBML template used to render a short story’s title, and template_body, which should map to the FBML template used to render a short story’s body.

Further, I think the RegisterTemplateBundle should handle building up the JSON itself.  The caller should just pass the template strings and not have to worrying about getting the JSON right. 

In short, I am thinking the RegisterTemplateBundle signature should look something like:

public string RegisterTemplateBundle(List<string> one_line_story_templates, Dictionary<string, string> short_story_templates, string full_story_template_title,  string full_story_template_body)

I hope that helps.  Thanks.
Jul 30, 2008 at 8:51 PM
Thanks TheRealMrT,

Your point is right. But the solution Ive added is just a temporary solution. Im currently using it until we get the version 2.0 launched. So, I thought that it would be great it if I share my code with you guys.

Thanks again.
Jul 30, 2008 at 10:18 PM

TheRealMrT,
Did you get the new news feed functionality working? If so, can you post the calling code and code that midowazzan originally posted that is to be placed in the v1.7 FacebookAPI. (The RegisterTemplateBundle and PublishUserAction methods are still not implemented in the latest source control version.

Thanks!

Jul 30, 2008 at 11:19 PM
first of all thanks for the code mido but unfortunately
I am getting the same error: The template data provided doesn't cover the entire token set needed to publish the story
looks like when we pass the template data somehow it doesn't match the tokes in the templates.I checked the template and the data it looks fine  I don't know why but I am checking.

Jul 30, 2008 at 11:42 PM
ok the problem was because I wasn't using target as a token in my template.by default mido's code is passing the targetId which cause facebook to return the error when you don't use that. I published a template but it is one line.
I think apps are by default allowed to publish one line templates and for the short should prompt user ? I am not sure how this is going to happen with iframe apps.it just sucks.
Jul 31, 2008 at 12:48 AM
ersin,

To prompt the user you need to Feed Forms. its FBML component.

There is a way to use them in iframe :

http://wiki.developers.facebook.com/index.php/Creating_a_Popup_Dialog_in_an_IFrame

http://svn.facebook.com/svnroot/platform/samples/smiley/iframe/
Jul 31, 2008 at 10:23 AM
hi mido, thanks.What I am concerned about by default this access is not granted to the apps.I think one line stories are useless.and it's a lot steps to display popup authorize etc everytime a news feed published.
Jul 31, 2008 at 10:08 PM
ersin, so you were able to successfully publish a one line template? if so, can you post the code used to do that? You said, "mido's code is passing the targetId which cause facebook to return the error when you don't use that". What does this mean exactly? what was your fix?
thanks
Aug 1, 2008 at 8:54 AM
yes, sorry for being not clear about the resolution. He was adding the target_Id parameter to the service call.Since I wasn't using that I removed that.Instead of removing it, I believe adding that to the template data properly  (using userId) should work as well. here is the code that I removed:


parameterList.Add("target_ids", target_ids); // comma separted

(inside publish user action function)
Aug 21, 2008 at 7:50 PM
Edited Aug 22, 2008 at 11:13 AM
Update: found my mistake, publishing works fine now.

But the following point I do not understand: I'm only publishing "one line stories". How can I publish a short or full story?
Aug 28, 2008 at 2:50 PM
feed.RegisterTemplateBundle is now included in the 2.0 kit. Still can't find feed.publishUserAction in the 2.0 release. Will this be coming soon, or do we have to hack it with the actual FB API string?
Sep 6, 2008 at 4:19 AM
This is working well for me, with one exception: even when I specify the target_ids, the story is never published to those user's feeds. It only publishes to the acting user's feed.

I've confirmed that they allow the app to publish, and indeed they are able to publish to their own feed when using the app. I just can't get it to respond to the targets.

Any ideas?
Sep 7, 2008 at 1:05 AM
Im not using the code above to publish stories on the target side. TargetId helps to combine the stories together.

:)
Sep 7, 2008 at 1:15 AM
I'm not sure I understand. What do you mean "helps to combine the stories together?" 

I thought specifying the targetid would make Facebook automatically publish the story to the provided targets. If I'm wrong, what do I need to do to publish a story to both an actor and a target?
Sep 7, 2008 at 1:19 AM
With combine I meant "Aggregation "

As far as I know, you need to use the FBML feed form to publish on the target side.
Sep 7, 2008 at 1:23 AM
Sorry, which API call are you referring to by "FBML feed form" ? 
Sep 7, 2008 at 1:25 AM
it is not API call.


take a look at this

http://wiki.developers.facebook.com/index.php/New_Design_Feed_Forms

Sep 7, 2008 at 1:30 AM
Thanks for that link.

So, if I'm understanding you correctly, it's not possible for a submission to postUserAction (or any other API for that matter) to publish the story both to actor and target feeds?

If that's the case, I'm not sure I understand the point of the target_ids param in postUserAction <?>
Sep 7, 2008 at 1:33 AM
As I said, it might be used to for Aggregation .

Anyway, you can remove the target thing.
Sep 7, 2008 at 1:36 AM
No, no, I'm not criticizing. I wish the Facebook API reference was clearer about these things. I guess I just jumped to what felt like the obvious conclusion.

I suppose the logic of it must have to do with reducing newsfeed spam. But it's still disappointing that it seems impossible to publish to both actor and target, yeah?
Sep 7, 2008 at 1:40 AM
You can publish on the target side once they access the application.

But its better to use the feed forms.



Sep 7, 2008 at 1:51 AM
I think I understand. So, if I'm understanding you correctly, I can publish to the target after they authorize the application. But in my experience with postUserAction, I still can't post to the  target in such a case.

I grasp the feed form concept now; it seems overbearing for both developer and user, but I guess that's the facebook way :-/
Sep 8, 2008 at 1:49 AM
Well, I got this working using the feed forms. It was completely unintuitive and highlights just how much the facebook api's expectations correspond with a very particular method of web dev, one that is very much NOT conducive to ASP.NET's features. 

The only thing I haven't been able to get working is the fbnext property, which is supposed to forward the page, but doesn't. I guess that's a detail.
Sep 8, 2008 at 8:40 AM
@ ibogost
Do you have some sample code and is it possible to combine feed forms with the multi friend selector respectively?
Sep 8, 2008 at 12:58 PM
Edited Sep 8, 2008 at 12:59 PM
Basically what you have to do is give up on ASP.NET's server control/postback model and go back to old-school form posting. You can combine them a bit, but having more than one <form> on a page seems to completely wonk out facebook's parser, so you'll need to do it in separate steps. Here's what I did:

<asp:Panel id="choosefriendpanel" runat="server">
     Choose a friend: <fb:friend-selector idname="recipient_id" /> &nbsp; <asp:Button id="NextButton" CssClass="inputsubmit" runat="server" Text="Next" />
</asp:Panel>

<asp:Panel id="mainformpanel" runat="server" visible="false">
     <form fbtype="multiFeedStory" action="[URI to ANOTHER aspx handler]">
          <!-- 
                Add your form inputs here, in normal HTML format, e.g.
                <input type="text" id="message" name="message"></input>
          -->
          <input type="submit" class="inputsubmit" Label="Send to %N Now" fbuid="<% = feedFormUid %>" />
     </form>
</asp:Panel>

In your form aspx codebehind, on postback I take the value from Request.Forms.Get("recipient_id") and put that value in the public class variable feedFormUid. Then I set the choosefriendpanel visible to false and the mainformpanel visible to true. Then I used a different ASPX page to handle the form input, although it's probably possible to ram it all into one somehow if you can turn all the HTML output off. In that page I did my form processing based on Request.Form data rather than postback data, and when successful output the JSON. Note that the JSON format on Facebook's reference page is wrong and will never work. Here's the correct format:

{"content":
    {"feed":
        {"template_id":123456789,
        "template_data":
            {"key1":"value2",
            "key2":"value2"
            }
        }
    },
"method":"multiFeedStory",
"next":"http://url.to.go.next"
}

Like I said, I still haven't gotten "next" working, and I had to remove a bunch of smart error correction code to get this into another form, and I haven't figured out how to hand an error back to facebook via JSON yet. But, this method does post to both the friend feeds of {actor} and {target} as specified in the template.

Incidentally, I had to split this into two forms because I couldn't for the life of me get Facebook to recognize the friend selector if I put the whole form together on one page. The entire system seems very taped together and works about as poorly as I could imagine .

I haven't tried this for a multiFriendSelector, but it should work just the same.