Exemplo n.º 1
0
        private int RegisterCustomTags(IEnumerable <CustomTag> tags, bool isAsync, RegisterCustomTagsCallback callback, Object state)
        {
            var parameterList = new Dictionary <string, string> {
                { "method", "facebook.fbml.registerCustomTags" }
            };
            var list = new List <string>();

            foreach (var item in tags)
            {
                var dict = new Dictionary <string, string> {
                    { "name", item.Name },
                    { "type", item.Type },
                    { "is_public", item.IsPublic.ToString() },
                    { "description", item.Description },
                    { "fbml", item.FBML },
                    { "open_tag_fbml", item.OpenTagFBML },
                    { "close_tag_fbml", item.CloseTagFBML },
                    { "header_fbml", item.HeaderFBML },
                    { "footer_fbml", item.FooterFBML }
                    //{"label", tag.name},
                    //{"type", tag.type.ToString(CultureInfo.InvariantCulture)},
                    //{"description", tag.description},
                    //{"fbml", tag.body},
                    //{"open_tag", tag.open_tag},
                    //{"close_tag", tag.close_tag},
                };
                var attribList = new List <string>();
                foreach (var attrib in item.Attributes)
                {
                    var dict2 = new Dictionary <string, string> {
                        { "default_value", attrib.DefaultValue },
                        { "description", attrib.Description },
                        { "name", attrib.Name }
                    };
                    attribList.Add(JSONHelper.ConvertToJSONAssociativeArray(dict2));
                }
                dict.Add("attributes", JSONHelper.ConvertToJSONArray(attribList));
                list.Add(JSONHelper.ConvertToJSONAssociativeArray(dict));
            }
            Utilities.AddJSONArray(parameterList, "tags", list);
            //parameterList.Add("tags", JSONHelper.ConvertToJSONArray(itemList));

            if (isAsync)
            {
                SendRequestAsync <fbml_registerCustomTags_response, int>(parameterList, new FacebookCallCompleted <int>(callback), state);
                return(0);
            }

            var response = SendRequest <fbml_registerCustomTags_response>(parameterList);

            return(response == null ? 0 : response.TypedValue);
        }
        private int RegisterCustomTags(IEnumerable<CustomTag> tags, bool isAsync, RegisterCustomTagsCallback callback, Object state)
        {
            var parameterList = new Dictionary<string, string> { { "method", "facebook.fbml.registerCustomTags" } };
            var list = new List<string>();
            foreach (var item in tags)
            {
                var dict = new Dictionary<string, string>{
                    {"name", item.Name},
                    {"type", item.Type},
                    {"is_public", item.IsPublic.ToString()},
                    {"description", item.Description},
                    {"fbml", item.FBML},
                    {"open_tag_fbml", item.OpenTagFBML},
                    {"close_tag_fbml", item.CloseTagFBML},
                    {"header_fbml", item.HeaderFBML},
                    {"footer_fbml", item.FooterFBML}
                    //{"label", tag.name},
                    //{"type", tag.type.ToString(CultureInfo.InvariantCulture)},
                    //{"description", tag.description},
                    //{"fbml", tag.body},
                    //{"open_tag", tag.open_tag},
                    //{"close_tag", tag.close_tag},
                };
                var attribList = new List<string>();
                foreach (var attrib in item.Attributes)
                {
                    var dict2 = new Dictionary<string, string>{
                    {"default_value", attrib.DefaultValue},
                    {"description", attrib.Description},
                    {"name", attrib.Name}};
                    attribList.Add(JSONHelper.ConvertToJSONAssociativeArray(dict2));
                }
                dict.Add("attributes", JSONHelper.ConvertToJSONArray(attribList));
                list.Add(JSONHelper.ConvertToJSONAssociativeArray(dict));
            }
            Utilities.AddJSONArray(parameterList, "tags", list);
            //parameterList.Add("tags", JSONHelper.ConvertToJSONArray(itemList));

            if (isAsync)
            {
                SendRequestAsync<fbml_registerCustomTags_response, int>(parameterList, new FacebookCallCompleted<int>(callback), state);
                return 0;
            }

            var response = SendRequest<fbml_registerCustomTags_response>(parameterList);
            return response == null ? 0 : response.TypedValue;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Registers custom tags you can include in your that applications' FBML markup. Custom tags consist of FBML snippets that are rendered during parse time on the containing page that references the custom tag.
 /// </summary>
 /// <example>
 /// <code>
 /// private static void RunDemoAsync()
 /// {
 ///     Api api = new Api(new FBMLCanvasSession(Constants.WebApplicationKey, Constants.WebSecret));
 ///     api.Session.UserId = Constants.UserId;
 ///
 ///     List&lt;CustomTag&gt; tags = new List&lt;CustomTag&gt;();
 ///     tags.Add(new CustomTag()
 ///     {
 ///         Name = "video",
 ///         Type = "leaf",
 ///         Description = "Renders a fb:swf tag that shows a video from my-video-site.tv. The video  is 425 pixels wide and 344 pixels tall.",
 ///         Attributes = new List&lt;CustomTagAttribute&gt;() { new CustomTagAttribute() { Name = "id", Description = "the id of the video", DefaultValue = "1234" } },
 ///         FBML = "&lt;div class=\"my_videos_element\"&gt;&lt;fb:swf swfsrc=\"http://my-video-site.tv/videos/${id}\" width=\"425\" height=\"344\"/&gt;&lt;/div&gt;",
 ///         HeaderFBML = "&lt;style&gt;div.my_videos_element { border: black solid 1px; padding: 5px;}&lt;/style&gt;"
 ///     });
 ///
 ///     tags.Add(new CustomTag()
 ///     {
 ///         Name = "gallery",
 ///         Type = "container",
 ///         Description = "Renders a standard header and footer around one or more \"video\" tags. The header contains the gallery's title, which the user can specify",
 ///         Attributes = new List&lt;CustomTagAttribute&gt;() { new CustomTagAttribute() { Name = "title", Description = "the title of the gallery" } },
 ///         OpenTagFBML = "&lt;div class=\"my_videos_element\"&gt;&lt;div class=\"video_gallery_title\"&gt;${title}&lt;/div&gt;&lt;div class=\"my_videos_gallery\"&gt;",
 ///         CloseTagFBML = "&lt;/div&gt;&lt;/div&gt;",
 ///         HeaderFBML = "&lt;style&gt;div.my_videos_element { border: black solid 1px; padding: 5px;}&lt;/style&gt;"
 ///     });
 ///
 ///     api.Fbml.RegisterCustomTagsAsync(tags, AsyncDemoCompleted, null);
 /// }
 ///
 /// private static void AsyncDemoCompleted(int result, Object state, FacebookException e)
 /// {
 ///     var actual = result;
 /// }
 /// </code>
 /// </example>
 /// <param name="tags">a List of CustomTag objects (See remarks for more detail.)</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 the identifier of the custom tag.</returns>
 /// <remarks>
 /// Each tag object is an object with the following properties:
 ///   name (required) (string): the name of the tag. The name must be a string up to 30 characters. Only letters, numbers, underscores ('_') and hyphens ('-') are allowed.
 ///   type (optional) (string): Specify either leaf or container. Leaf tags can't contain any other tags (similar to &lt;fb:name/&gt;). Container tags may contain children between their open and close tags (like &lt;fb:editor&gt; &lt;/fb:editor&gt;). (Default value is leaf.).
 ///   description (optional) (string): A full description of the tag's functionality. This is used for documentation only, and is especially useful for public tags.
 ///   is_public (optional) (string): Specify either true or false. Specifying true indicates that other applications can use this tag. You can have a mix of public and private tags within the same array. (Default value is false.).
 ///   attributes (optional) (mixed): A list of attribute objects. Attributes are used to add dynamic elements to tags. The values of those attributes are substituted into the tag's FBML before it's parsed. Each attribute has the following fields:
 ///   name (required) (string): The attribute's name. The name must be a string up to 30 characters in length. Only letters, numbers, underscores ('_') and hyphens ('-') are allowed.
 ///   description (optional) (string): The attribute's description. This is used for documentation only, and is especially useful for public tags.
 ///   default_value (optional) (string): The value to use when the attribute is missing. If an attribute doesn't have a default value, it is considered to be required and the developer will see an error message if the attribute is missing.
 ///   fbml (required) (string): The FBML markup to substitute into the page where the tag is encountered. This property is required only for leaf tags.
 ///   open_tag_fbml (required) (string): The FBML markup to substitute into the page where the open tag appears. This property is required for container tags only.
 ///   close_tag_fbml (required) (string): The FBML markup to substitute into the page where the close tag appears. This property is required for container tags only. Note: Facebook recommends you do not include &lt;script&gt; tags in this FBML snippet.
 ///   header_fbml: An FBML snippet that is rendered once on the page before the first tag that defined it. If multiple tags define the same value for header_fbml, and more than one of them appear on a page, then header_fbml is rendered only once. You should only use this for including CSS and initializing any JavaScript variables, not for rendering visible content. Facebook recommends you avoid including heavy JavaScript libraries and performing expensive JavaScript operations in header_fbml for performance reasons. Instead, use footer_fbml.
 ///   footer_fbml: Similar to header_fbml, it's an FBML snippet that gets rendered after all custom tags are rendered. Facebook recommends you include heavy JavaScript libraries and perform any expensive JavaScript operations in footer_fbml, and avoid them in fbml, open_tag_fbml, close_tag_fbml, and header_fbml.
 /// </remarks>
 public void RegisterCustomTagsAsync(List <CustomTag> tags, RegisterCustomTagsCallback callback, Object state)
 {
     RegisterCustomTags(tags, true, callback, state);
 }
 /// <summary>
 /// Registers custom tags you can include in your that applications' FBML markup. Custom tags consist of FBML snippets that are rendered during parse time on the containing page that references the custom tag.
 /// </summary>
 /// <example>
 /// <code>
 /// private static void RunDemoAsync()
 /// {
 ///     Api api = new Api(new FBMLCanvasSession(Constants.WebApplicationKey, Constants.WebSecret));
 ///     api.Session.UserId = Constants.UserId;
 ///
 ///     List&lt;CustomTag&gt; tags = new List&lt;CustomTag&gt;();
 ///     tags.Add(new CustomTag()
 ///     {
 ///         Name = "video",
 ///         Type = "leaf",
 ///         Description = "Renders a fb:swf tag that shows a video from my-video-site.tv. The video  is 425 pixels wide and 344 pixels tall.",
 ///         Attributes = new List&lt;CustomTagAttribute&gt;() { new CustomTagAttribute() { Name = "id", Description = "the id of the video", DefaultValue = "1234" } },
 ///         FBML = "&lt;div class=\"my_videos_element\"&gt;&lt;fb:swf swfsrc=\"http://my-video-site.tv/videos/${id}\" width=\"425\" height=\"344\"/&gt;&lt;/div&gt;",
 ///         HeaderFBML = "&lt;style&gt;div.my_videos_element { border: black solid 1px; padding: 5px;}&lt;/style&gt;"
 ///     });
 ///
 ///     tags.Add(new CustomTag()
 ///     {
 ///         Name = "gallery",
 ///         Type = "container",
 ///         Description = "Renders a standard header and footer around one or more \"video\" tags. The header contains the gallery's title, which the user can specify",
 ///         Attributes = new List&lt;CustomTagAttribute&gt;() { new CustomTagAttribute() { Name = "title", Description = "the title of the gallery" } },
 ///         OpenTagFBML = "&lt;div class=\"my_videos_element\"&gt;&lt;div class=\"video_gallery_title\"&gt;${title}&lt;/div&gt;&lt;div class=\"my_videos_gallery\"&gt;",
 ///         CloseTagFBML = "&lt;/div&gt;&lt;/div&gt;",
 ///         HeaderFBML = "&lt;style&gt;div.my_videos_element { border: black solid 1px; padding: 5px;}&lt;/style&gt;"
 ///     });
 ///
 ///     api.Fbml.RegisterCustomTagsAsync(tags, AsyncDemoCompleted, null);
 /// }
 ///
 /// private static void AsyncDemoCompleted(int result, Object state, FacebookException e)
 /// {
 ///     var actual = result;
 /// }
 /// </code>
 /// </example>
 /// <param name="tags">a List of CustomTag objects (See remarks for more detail.)</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 the identifier of the custom tag.</returns>
 /// <remarks>
 /// Each tag object is an object with the following properties:
 ///   name (required) (string): the name of the tag. The name must be a string up to 30 characters. Only letters, numbers, underscores ('_') and hyphens ('-') are allowed.
 ///   type (optional) (string): Specify either leaf or container. Leaf tags can't contain any other tags (similar to &lt;fb:name/&gt;). Container tags may contain children between their open and close tags (like &lt;fb:editor&gt; &lt;/fb:editor&gt;). (Default value is leaf.).
 ///   description (optional) (string): A full description of the tag's functionality. This is used for documentation only, and is especially useful for public tags.
 ///   is_public (optional) (string): Specify either true or false. Specifying true indicates that other applications can use this tag. You can have a mix of public and private tags within the same array. (Default value is false.).
 ///   attributes (optional) (mixed): A list of attribute objects. Attributes are used to add dynamic elements to tags. The values of those attributes are substituted into the tag's FBML before it's parsed. Each attribute has the following fields:
 ///   name (required) (string): The attribute's name. The name must be a string up to 30 characters in length. Only letters, numbers, underscores ('_') and hyphens ('-') are allowed.
 ///   description (optional) (string): The attribute's description. This is used for documentation only, and is especially useful for public tags.
 ///   default_value (optional) (string): The value to use when the attribute is missing. If an attribute doesn't have a default value, it is considered to be required and the developer will see an error message if the attribute is missing.
 ///   fbml (required) (string): The FBML markup to substitute into the page where the tag is encountered. This property is required only for leaf tags.
 ///   open_tag_fbml (required) (string): The FBML markup to substitute into the page where the open tag appears. This property is required for container tags only.
 ///   close_tag_fbml (required) (string): The FBML markup to substitute into the page where the close tag appears. This property is required for container tags only. Note: Facebook recommends you do not include &lt;script&gt; tags in this FBML snippet.
 ///   header_fbml: An FBML snippet that is rendered once on the page before the first tag that defined it. If multiple tags define the same value for header_fbml, and more than one of them appear on a page, then header_fbml is rendered only once. You should only use this for including CSS and initializing any JavaScript variables, not for rendering visible content. Facebook recommends you avoid including heavy JavaScript libraries and performing expensive JavaScript operations in header_fbml for performance reasons. Instead, use footer_fbml.
 ///   footer_fbml: Similar to header_fbml, it's an FBML snippet that gets rendered after all custom tags are rendered. Facebook recommends you include heavy JavaScript libraries and perform any expensive JavaScript operations in footer_fbml, and avoid them in fbml, open_tag_fbml, close_tag_fbml, and header_fbml.
 /// </remarks>
 public void RegisterCustomTagsAsync(List<CustomTag> tags, RegisterCustomTagsCallback callback, Object state)
 {
     RegisterCustomTags(tags, true, callback, state);
 }