Example #1
0
        public void registerTemplateBundleTest()
        {
            var parent = _api;
            var target = parent.feed;
            string oneLineStoryTemplate = "{*actor*} has been playing.";
            string shortStoryTemplateTitle = "{*actor*} has been <a href='http://www.facebook.com/apps/application.php?id=xxx>Playing Poker!</a>";
            string shortStoryTemplateBody = "short story body";
            string fullStoryTemplateTitle = "{*actor*} has been <a href='http://www.facebook.com/apps/application.php?id=xxx>Playing Poker!</a>";
            string fullStoryTemplateBody = "full story body";
            template_bundle expected;
            long actual;
            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 };

            actual = target.registerTemplateBundle(oneLineTemplates, shortStoryTemplates, fullStoryTemplate);
            expected = target.getRegisteredTemplateBundleByID(actual);
            Assert.AreEqual(expected.template_bundle_id, actual);
        }
Example #2
0
        /// <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. You need to register at least one bundle for each of your applications, if you have more than one.
        /// </summary>
        /// <param name="oneLineStoryTemplates"></param>
        /// <param name="fullStoryTemplate"></param>
        /// <param name="shortStoryTemplates"></param>
        public long registerTemplateBundle(List<string> oneLineStoryTemplates, List<feedTemplate> shortStoryTemplates, feedTemplate fullStoryTemplate)
        {
            var parameterList = new Dictionary<string, string> { { "method", "facebook.feed.registerTemplateBundle" } };

            _api.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));
            }
            _api.AddJSONArray(parameterList, "short_story_templates", list);

            var full_story_template = new Dictionary<string, string>();
            full_story_template.Add("template_title", fullStoryTemplate.TemplateTitle);
            full_story_template.Add("template_body", fullStoryTemplate.TemplateBody);
            _api.AddJSONAssociativeArray(parameterList, "full_story_template", full_story_template);

            var response = _api.SendRequest(parameterList);
            return !string.IsNullOrEmpty(response) ? feed_registerTemplateBundle_response.Parse(response).TypedValue : 0;
        }