internal void AddJSONArray(IDictionary <string, string> dict, string key, List <string> value) { if (value != null && value.Count > 0) { dict.Add(key, JSONHelper.ConvertToJSONArray(value)); } }
private long UploadNativeStrings(List <native_string> native_strings, bool isAsync, UploadNativeStringsCallback callback, Object state) { var parameterList = new Dictionary <string, string> { { "method", "facebook.intl.uploadNativeStrings" } }; var translationList = new List <string>(); foreach (var item in native_strings) { var translation = new Dictionary <string, string> { { "text", item.text }, { "description", item.description } }; translationList.Add(JSONHelper.ConvertToJSONAssociativeArray(translation)); } Utilities.AddRequiredParameter(parameterList, "native_strings", JSONHelper.ConvertToJSONArray(translationList)); if (isAsync) { SendRequestAsync <intl_uploadNativeStrings_response, long>(parameterList, !string.IsNullOrEmpty(Session.SessionKey), new FacebookCallCompleted <long>(callback), state); return(0); } var response = SendRequest <intl_uploadNativeStrings_response>(parameterList, !string.IsNullOrEmpty(Session.SessionKey)); return(response == null ? -1 : 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); }
private string TemplateImagesGen(string imgPath, string URL) { List <string> jsonPaths = new List <string>(); Dictionary <string, string> path = new Dictionary <string, string>(); imgPath = LIB.Util.ApplicationRootPath() + imgPath; //imgPath = "http://www.hayatidoldur.com/Image.ashx?t=1&p=HayatiDoldur_00034_01_300909-133808,1.jpeg&sz=1"; //Test Images path.Add("src", imgPath); path.Add("href", URL); path.Add("target", "_blank"); jsonPaths.Add(JSONHelper.ConvertToJSONAssociativeArray(path)); return(JSONHelper.ConvertToJSONArray(jsonPaths)); }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.Params["picked"])) { var picked = int.Parse(Request.Params["picked"]); var moodList = JSONHelper.ConvertFromJSONArray(this.Api.Data.GetUserPreference(0)); moodList.Insert(0, picked.ToString()); this.Api.Data.SetUserPreference(0, JSONHelper.ConvertToJSONArray(moodList)); var oldCount = 0; if (!string.IsNullOrEmpty(this.Api.Data.GetUserPreference(2))) { oldCount = int.Parse(this.Api.Data.GetUserPreference(2)); } this.Api.Data.SetUserPreference(2, (oldCount + 1).ToString()); } }
private bool SetInfo(string title, int type, List <info_field> info_fields, long uid, bool isAsync, SetInfoCallback callback, Object state) { var parameterList = new Dictionary <string, string> { { "method", "facebook.profile.setInfo" } }; Utilities.AddRequiredParameter(parameterList, "title", title); Utilities.AddRequiredParameter(parameterList, "type", type); var fieldList = new List <string>(); foreach (var field in info_fields) { var itemList = new List <string>(); foreach (var item in field.items.info_item) { var itemDict = new Dictionary <string, string> { { "label", item.label }, { "sublabel", item.sublabel }, { "link", item.link }, { "image", item.image }, { "description", item.description } }; itemList.Add(JSONHelper.ConvertToJSONAssociativeArray(itemDict)); } var fieldDict = new Dictionary <string, string> { { "field", field.field }, { "items", JSONHelper.ConvertToJSONArray(itemList) } }; fieldList.Add(JSONHelper.ConvertToJSONAssociativeArray(fieldDict)); } Utilities.AddJSONArray(parameterList, "info_fields", fieldList); Utilities.AddRequiredParameter(parameterList, "uid", uid); if (isAsync) { SendRequestAsync <profile_setInfo_response, bool>(parameterList, !string.IsNullOrEmpty(Session.SessionKey), new FacebookCallCompleted <bool>(callback), state); return(true); } var response = SendRequest <profile_setInfo_response>(parameterList, !string.IsNullOrEmpty(Session.SessionKey)); return(response == null ? false : response.TypedValue); }
private IList <string> UnregisterUsers(List <string> email_hashes, bool isAsync, UnregisterUsersCallback callback, Object state) { var parameterList = new Dictionary <string, string> { { "method", "facebook.connect.unregisterUsers" } }; Utilities.AddRequiredParameter(parameterList, "email_hashes", JSONHelper.ConvertToJSONArray(email_hashes)); if (isAsync) { SendRequestAsync <connect_unregisterUsers_response, IList <string> >(parameterList, !string.IsNullOrEmpty(Session.SessionKey), new FacebookCallCompleted <IList <string> >(callback), state); return(null); } var response = SendRequest <connect_unregisterUsers_response>(parameterList, !string.IsNullOrEmpty(Session.SessionKey)); return(response.connect_unregisterUsers_response_elt); }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.Params["picked"])) { var picked = int.Parse(Request.Params["picked"]); var basePage = new BasePage(); var moods = basePage.getMoods(); var canvas = string.Format("http://apps.facebook.com/{0}/mysmiles.apsx", suffix); var moodList = JSONHelper.ConvertFromJSONArray(this.Api.Data.GetUserPreference(0)); moodList.Insert(0, picked.ToString()); this.Api.Data.SetUserPreference(0, JSONHelper.ConvertToJSONArray(moodList)); var oldCount = 0; if (!string.IsNullOrEmpty(this.Api.Data.GetUserPreference(2))) { oldCount = int.Parse(this.Api.Data.GetUserPreference(2)); } this.Api.Data.SetUserPreference(2, (oldCount + 1).ToString()); var image = string.Format("{0}images/smile{1}.jpg", callback, picked); var images = JSONHelper.ConvertToJSONAssociativeArray(new Dictionary <string, string> { { "src", image }, { "href", canvas } }); var templateData = JSONHelper.ConvertToJSONAssociativeArray( new Dictionary <string, string> { { "mood", moods.ElementAt(picked).Value }, { "emote", moods.ElementAt(picked).Key }, { "images", images }, { "mood_src", image } }); var feed = JSONHelper.ConvertToJSONAssociativeArray( new Dictionary <string, string> { { "template_id", basePage.FeedTemplate1.ToString() }, { "template_data", templateData } }); var content = JSONHelper.ConvertToJSONAssociativeArray( new Dictionary <string, string> { { "feed", feed }, { "next", canvas } }); var data = JSONHelper.ConvertToJSONAssociativeArray( new Dictionary <string, string> { { "method", "feedStory" }, { "content", content } }); json = data; } else { throw new Exception("no smile picked"); } }
///// <summary> ///// Configures an application info section that the specified user can install on the Info tab of her profile. ///// </summary> ///// <param name="title">The title or header of the application info section. </param> ///// <param name="type">Specify 1 for a text-only field-item configuration or 5 for a thumbnail configuration.</param> ///// <param name="info_fields">A JSON-encoded array of elements comprising an application info section, including the field (the title of the field) and an array of info_item objects (each object has a label and a link, and optionally contains image, description, and sublabel fields. </param> ///// <param name="uid">The user ID of the user adding the application info section. </param> ///// <returns></returns> public bool setInfo(string title, int type, List <info_field> info_fields, long uid) { var parameterList = new Dictionary <string, string> { { "method", "facebook.profile.setInfo" } }; _api.AddRequiredParameter(parameterList, "title", title); _api.AddRequiredParameter(parameterList, "type", type); var fieldList = new List <string>(); foreach (var field in info_fields) { var itemList = new List <string>(); foreach (var item in field.items.info_item) { var itemDict = new Dictionary <string, string> { { "label", item.label }, { "sublabel", item.sublabel }, { "link", item.link }, { "image", item.image }, { "description", item.description } }; itemList.Add(JSONHelper.ConvertToJSONAssociativeArray(itemDict)); } var fieldDict = new Dictionary <string, string> { { "field", field.field }, { "items", JSONHelper.ConvertToJSONArray(itemList) } }; fieldList.Add(JSONHelper.ConvertToJSONAssociativeArray(fieldDict)); } _api.AddJSONArray(parameterList, "info_fields", fieldList); _api.AddRequiredParameter(parameterList, "uid", uid); var response = _api.SendRequest(parameterList); return(!string.IsNullOrEmpty(response) ? profile_setInfo_response.Parse(response).TypedValue : false); }
private IList <string> RegisterUsers(ICollection <ConnectAccountMap> accountMaps, bool isAsync, RegisterUsersCallback callback, Object state) { var parameterList = new Dictionary <string, string> { { "method", "facebook.connect.registerUsers" } }; var itemList = new List <string>(); foreach (var accountMap in accountMaps) { var mappingDictionary = new Dictionary <string, string>(); // Compute the email_hash mappingDictionary.Add("email_hash", Utilities.GenerateEmailHash(accountMap.EmailAddress)); // If populated set AccountId if (!string.IsNullOrEmpty(accountMap.AccountId)) { mappingDictionary.Add("account_id", accountMap.AccountId); } // If populated set AccountUrl if (!string.IsNullOrEmpty(accountMap.AccountUrl)) { mappingDictionary.Add("account_url", accountMap.AccountUrl); } itemList.Add(JSONHelper.ConvertToJSONAssociativeArray(mappingDictionary)); } Utilities.AddRequiredParameter(parameterList, "accounts", JSONHelper.ConvertToJSONArray(itemList)); if (isAsync) { SendRequestAsync <connect_registerUsers_response, IList <string> >(parameterList, !string.IsNullOrEmpty(Session.SessionKey), new FacebookCallCompleted <IList <string> >(callback), state); return(null); } var response = SendRequest <connect_registerUsers_response>(parameterList, !string.IsNullOrEmpty(Session.SessionKey)); return(response.connect_registerUsers_response_elt); }
/// <summary> /// /// </summary> /// <returns></returns> public string publish(string message, attachment attachment, IList <action_link> action_links, string target_id, int uid) { var parameterList = new Dictionary <string, string> { { "method", "facebook.stream.publish" } }; _api.AddOptionalParameter(parameterList, "message", message); if (attachment != null) { var mediaList = new List <string>(); var cat = new Dictionary <string, string> { { "text", attachment.properties.category.text }, { "href", attachment.properties.category.href } }; var prop = new Dictionary <string, string> { { "category", JSONHelper.ConvertToJSONAssociativeArray(cat) }, { "ratings", attachment.properties.ratings } }; if (attachment.media != null) { foreach (var item in attachment.media) { var media = new Dictionary <string, string> { { "type", item.type.ToString() } }; if (item.type == attachment_media_type.image) { var image = item as attachment_media_image; media.Add("src", image.src); media.Add("href", image.href); } else if (item.type == attachment_media_type.flash) { var flash = item as attachment_media_flash; media.Add("swfsrc", flash.swfsrc); media.Add("imgsrc", flash.imgsrc); media.Add("width", flash.width.ToString()); media.Add("height", flash.height.ToString()); media.Add("expanded_width", flash.expanded_width.ToString()); media.Add("expanded_height", flash.expanded_height.ToString()); } else if (item.type == attachment_media_type.mp3) { var mp3 = item as attachment_media_mp3; media.Add("src", mp3.src); media.Add("title", mp3.title); media.Add("artist", mp3.artist); media.Add("album", mp3.album); } else { var video = item as attachment_media_video; media.Add("video_src", video.video_src); media.Add("preview_img", video.preview_img); media.Add("video_link", video.video_link); media.Add("video_title", video.video_title); } mediaList.Add(JSONHelper.ConvertToJSONAssociativeArray(media)); } } var dict = new Dictionary <string, string> { { "name", attachment.name }, { "href", attachment.href }, { "caption", attachment.caption }, { "description", attachment.description }, { "properties", JSONHelper.ConvertToJSONAssociativeArray(prop) }, { "media", JSONHelper.ConvertToJSONArray(mediaList) }, { "latitude", attachment.latitude }, { "longitude", attachment.longitude } }; _api.AddOptionalParameter(parameterList, "attachment", JSONHelper.ConvertToJSONAssociativeArray(dict)); } if (action_links != null) { var list = new List <string>(); foreach (var item in action_links) { var dict = new Dictionary <string, string> { { "text", item.text }, { "href", item.href } }; list.Add(JSONHelper.ConvertToJSONAssociativeArray(dict)); } _api.AddJSONArray(parameterList, "action_links", list); } _api.AddOptionalParameter(parameterList, "target_id", target_id); _api.AddOptionalParameter(parameterList, "uid", uid); var response = _api.SendRequest(parameterList, uid <= 0); return(!string.IsNullOrEmpty(response) ? stream_publish_response.Parse(response).TypedValue : null); }