Facebook.AndroidFacebook.FeedRequest C# (CSharp) Method

FeedRequest() public method

public FeedRequest ( string toId = "", string link = "", string linkName = "", string linkCaption = "", string linkDescription = "", string picture = "", string mediaSource = "", string actionName = "", string actionLink = "", string reference = "", string[]>.Dictionary properties = null, FacebookDelegate callback = null ) : void
toId string
link string
linkName string
linkCaption string
linkDescription string
picture string
mediaSource string
actionName string
actionLink string
reference string
properties string[]>.Dictionary
callback FacebookDelegate
return void
        public override void FeedRequest(
            string toId = "",
            string link = "",
            string linkName = "",
            string linkCaption = "",
            string linkDescription = "",
            string picture = "",
            string mediaSource = "",
            string actionName = "",
            string actionLink = "",
            string reference = "",
            Dictionary<string, string[]> properties = null,
            FacebookDelegate callback = null)
        {
            Dictionary<string, object> paramsDict = new Dictionary<string, object>();
            // Marshal all the above into the thing

            if (callback != null)
            {
                paramsDict["callback_id"] = AddFacebookDelegate(callback);
            }

            if (!string.IsNullOrEmpty(toId))
            {
                paramsDict.Add("to", toId);
            }

            if (!string.IsNullOrEmpty(link))
            {
                paramsDict.Add("link", link);
            }

            if (!string.IsNullOrEmpty(linkName))
            {
                paramsDict.Add("name", linkName);
            }

            if (!string.IsNullOrEmpty(linkCaption))
            {
                paramsDict.Add("caption", linkCaption);
            }

            if (!string.IsNullOrEmpty(linkDescription))
            {
                paramsDict.Add("description", linkDescription);
            }

            if (!string.IsNullOrEmpty(picture))
            {
                paramsDict.Add("picture", picture);
            }

            if (!string.IsNullOrEmpty(mediaSource))
            {
                paramsDict.Add("source", mediaSource);
            }

            if (!string.IsNullOrEmpty(actionName) && !string.IsNullOrEmpty(actionLink))
            {
                Dictionary<string, object> dict = new Dictionary<string, object>();
                dict.Add("name", actionName);
                dict.Add("link", actionLink);

                paramsDict.Add("actions", new[] { dict });
            }

            if (!string.IsNullOrEmpty(reference))
            {
                paramsDict.Add("ref", reference);
            }

            if (properties != null)
            {
                Dictionary<string, object> newObj = new Dictionary<string, object>();
                foreach (KeyValuePair<string, string[]> pair in properties)
                {
                    if (pair.Value.Length < 1)
                        continue;

                    if (pair.Value.Length == 1)
                    {
                        // String-string
                        newObj.Add(pair.Key, pair.Value[0]);
                    }
                    else
                    {
                        // String-Object with two parameters
                        Dictionary<string, object> innerObj = new Dictionary<string, object>();

                        innerObj.Add("text", pair.Value[0]);
                        innerObj.Add("href", pair.Value[1]);

                        newObj.Add(pair.Key, innerObj);
                    }
                }
                paramsDict.Add("properties", newObj);
            }

            CallFB("FeedRequest", MiniJSON.Json.Serialize(paramsDict));
        }