Example #1
0
        /// <summary>
        /// Get the facebook user id of the user associated with the current session
        /// </summary>
        /// <returns>facebook userid</returns>
        public string GetLoggedInUser()
        {
            List <string> arr = JSONHelper.ConvertFromJSONArray(ExecuteApiCallString(null, true, Resources.CurrentUser));

            //{id:628920325}
            // Only works if user id only contains digits
            return(System.Text.RegularExpressions.Regex.Match(arr[0], "\\d+").Groups[0].Value);
        }
Example #2
0
 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());
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            //TODO, Check Form POST to see if it is inside of a tab or not...
            List <string> moodList = JSONHelper.ConvertFromJSONArray(this.Master.Api.Data.GetUserPreference(0));

            lblMoodList.Text = buildMoodListFBML(moodList);
            if (!string.IsNullOrEmpty(lblMoodList.Text))
            {
                announce.Text = string.Format("We are pleased to announce that <fb:name useyou=\"false\" uid=\"{0}\"/> has been feeling:", Master.Api.Session.UserId);
            }
            else
            {
                announce.Text = string.Format("<fb:name useyou=\"false\" uid=\"{0}\"/> has never told us their feelings.", Master.Api.Session.UserId);
            }

            lblLink.Text = "<a href=\"http://apps.facebook.com/" + Master.suffix + "\">Check out Smiley</a>";
        }
 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");
     }
 }