/// <summary> /// Builds a template bundle around the specified templates, registers them on Facebook, and responds with a template bundle ID that can be used to identify your template bundle to other Feed-related API calls. /// </summary> /// <example> /// <code> /// private static void RunDemoAsync() /// { /// Api api = new Api(new DesktopSession(Constants.ApplicationKey, Constants.ApplicationSecret, Constants.SessionSecret, Constants.SessionKey)); /// /// string oneLineStoryTemplate = "{*actor*} has been playing."; /// string shortStoryTemplateTitle = "{*actor*} has been <a href='http://www.facebook.com/apps/application.php?id=xxx>testing!</a>"; /// string shortStoryTemplateBody = "short story body"; /// string fullStoryTemplateTitle = "{*actor*} has been <a href='http://www.facebook.com/apps/application.php?id=xxx>testing!</a>"; /// string fullStoryTemplateBody = "full story body"; /// List<string> oneLineTemplates = new List<string> { oneLineStoryTemplate }; /// feedTemplate shortStoryTemplate = new feedTemplate { PreferredLayout = "1", TemplateBody = shortStoryTemplateBody, TemplateTitle = shortStoryTemplateTitle }; /// List<feedTemplate> shortStoryTemplates = new List<feedTemplate> { shortStoryTemplate }; /// feedTemplate fullStoryTemplate = new feedTemplate { PreferredLayout = "1", TemplateBody = fullStoryTemplateBody, TemplateTitle = fullStoryTemplateTitle }; /// List<action_link> actionLinks = new List<action_link>(); /// actionLinks.Add(new action_link() { href = "http://www.facebook.com", text = "facebook link"}); /// /// api.Feed.RegisterTemplateBundleAsync(oneLineTemplates, shortStoryTemplates, fullStoryTemplate, actionLinks, AsyncDemoCompleted, null); /// } /// /// private static void AsyncDemoCompleted(long result, Object state, FacebookException e) /// { /// var actual = result; /// } /// </code> /// </example> /// <param name="oneLineStoryTemplates">array containing one FBML template that can be used to render one line Feed stories</param> /// <param name="shortStoryTemplates">Array of short story templates</param> /// <param name="fullStoryTemplate">template for a single full story</param> /// <param name="actionLinks">Array of action link records</param> /// <param name="callback">The AsyncCallback delegate</param> /// <param name="state">An object containing state information for this asynchronous request</param> /// <returns>This method returns an identifier that the developer can use to publish actual stories using that template bundle.</returns> public void RegisterTemplateBundleAsync(List<string> oneLineStoryTemplates, List<feedTemplate> shortStoryTemplates, feedTemplate fullStoryTemplate, IList<action_link> actionLinks, RegisterTemplateBundleCallback callback, Object state) { RegisterTemplateBundle(oneLineStoryTemplates, shortStoryTemplates, fullStoryTemplate, actionLinks, true, callback, state); }
private long RegisterTemplateBundle(List<string> oneLineStoryTemplates, List<feedTemplate> shortStoryTemplates, feedTemplate fullStoryTemplate, IList<action_link> actionLinks, bool isAsync, RegisterTemplateBundleCallback callback, Object state) { var parameterList = new Dictionary<string, string> { { "method", "facebook.feed.registerTemplateBundle" } }; Utilities.AddJSONArray(parameterList, "one_line_story_templates", oneLineStoryTemplates); var list = new List<string>(); foreach (var item in shortStoryTemplates) { var dict = new Dictionary<string, string>{ {"template_title", item.TemplateTitle}, {"template_body", item.TemplateBody}, {"preferred_layout", item.PreferredLayout} }; list.Add(JSONHelper.ConvertToJSONAssociativeArray(dict)); } Utilities.AddJSONArray(parameterList, "short_story_templates", list); if (actionLinks != null) { var alist = new List<string>(); foreach (action_link al in actionLinks) { var dict = new Dictionary<string, string>{ {"text", al.text}, {"href", al.href} }; alist.Add(JSONHelper.ConvertToJSONAssociativeArray(dict)); } Utilities.AddJSONArray(parameterList, "action_links", alist); } var full_story_template = new Dictionary<string, string>(); full_story_template.Add("template_title", fullStoryTemplate.TemplateTitle); full_story_template.Add("template_body", fullStoryTemplate.TemplateBody); Utilities.AddJSONAssociativeArray(parameterList, "full_story_template", full_story_template); if (isAsync) { SendRequestAsync<feed_registerTemplateBundle_response, long>(parameterList, !string.IsNullOrEmpty(Session.SessionKey), new FacebookCallCompleted<long>(callback), state); return 0; } var response = SendRequest<feed_registerTemplateBundle_response>(parameterList, !string.IsNullOrEmpty(Session.SessionKey)); return response == null ? 0 : response.TypedValue; }
/// <summary> /// Builds a template bundle around the specified templates, registers them on Facebook, and responds with a template bundle ID that can be used to identify your template bundle to other Feed-related API calls. /// </summary> /// <example> /// <code> /// private static void RunDemoAsync() /// { /// Api api = new Api(new DesktopSession(Constants.ApplicationKey, Constants.ApplicationSecret, Constants.SessionSecret, Constants.SessionKey)); /// /// string oneLineStoryTemplate = "{*actor*} has been playing."; /// string shortStoryTemplateTitle = "{*actor*} has been <a href='http://www.facebook.com/apps/application.php?id=xxx>testing!</a>"; /// string shortStoryTemplateBody = "short story body"; /// string fullStoryTemplateTitle = "{*actor*} has been <a href='http://www.facebook.com/apps/application.php?id=xxx>testing!</a>"; /// string fullStoryTemplateBody = "full story body"; /// List<string> oneLineTemplates = new List<string> { oneLineStoryTemplate }; /// feedTemplate shortStoryTemplate = new feedTemplate { PreferredLayout = "1", TemplateBody = shortStoryTemplateBody, TemplateTitle = shortStoryTemplateTitle }; /// List<feedTemplate> shortStoryTemplates = new List<feedTemplate> { shortStoryTemplate }; /// feedTemplate fullStoryTemplate = new feedTemplate { PreferredLayout = "1", TemplateBody = fullStoryTemplateBody, TemplateTitle = fullStoryTemplateTitle }; /// /// api.Feed.RegisterTemplateBundleAsync(oneLineTemplates, shortStoryTemplates, fullStoryTemplate, AsyncDemoCompleted, null); /// } /// /// private static void AsyncDemoCompleted(long result, Object state, FacebookException e) /// { /// var actual = result; /// } /// </code> /// </example> /// <param name="oneLineStoryTemplates">array containing one FBML template that can be used to render one line Feed stories</param> /// <param name="shortStoryTemplates">Array of short story templates</param> /// <param name="fullStoryTemplate">template for a single full story</param> /// <param name="callback">The AsyncCallback delegate</param> /// <param name="state">An object containing state information for this asynchronous request</param> /// <returns>This method returns an identifier that the developer can use to publish actual stories using that template bundle.</returns> public void RegisterTemplateBundleAsync(List<string> oneLineStoryTemplates, List<feedTemplate> shortStoryTemplates, feedTemplate fullStoryTemplate, RegisterTemplateBundleCallback callback, Object state) { RegisterTemplateBundleAsync(oneLineStoryTemplates, shortStoryTemplates, fullStoryTemplate, null, callback, state); }