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"); } }
protected void Page_Load(object sender, EventArgs e) { var basePage = new BasePage(); var moods = basePage.getMoods(); if (!string.IsNullOrEmpty(Request.Params["method"]) && Request.Params["method"] == "publisher_getFeedStory") { //TODO: need to figure out how to pull picked out of this var picked = 0; //int.Parse(Request.Params["app_params"]); var canvas = string.Format("http://apps.facebook.com/{0}/mysmiles.aspx", suffix); 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 } }); var data = JSONHelper.ConvertToJSONAssociativeArray( new Dictionary<string, string> { { "method", "publisher_getFeedStory" }, { "content", content } }); json = data; } else if (!string.IsNullOrEmpty(Request.Params["method"]) && Request.Params["method"] == "publisher_getInterface") { //TODO: need to figure out how to pull picked out of this var fbml = FBMLControlRenderer.RenderFBML<string>(string.Format("~/controls/PublisherHeader.ascx"), callback).Replace("\n",""); //var fbml = @"<style> //</style>"; //fbml += "test"; fbml += string.Format("<form>{0}<input type=\"hidden\" id=\"picked\" name=\"picked\" value=\"-1\"></form>", basePage.BuildEmoticonGrid(moods, callback, suffix, false)); var content = JSONHelper.ConvertToJSONAssociativeArray( new Dictionary<string, string> { { "fbml", fbml }, { "publishEnabled", "true" }, { "commentEnabled", "true" } }); var data = JSONHelper.ConvertToJSONAssociativeArray( new Dictionary<string, string> { { "content", content }, { "method", "publisher_getInterface" } }); json = data; } else { throw new Exception("no smile picked"); } }