public string GetAllFacebookGroups(string accessToken)
 {
     string client_id = ConfigurationManager.AppSettings["ClientId"];
     string redirect_uri = ConfigurationManager.AppSettings["RedirectUrl"];
     string client_secret = ConfigurationManager.AppSettings["ClientSecretKey"];
     List<Domain.Socioboard.Domain.AddFacebookGroup> lstAddFacebookGroup = new List<Domain.Socioboard.Domain.AddFacebookGroup>();
     FacebookClient fb = new FacebookClient();
     string profileId = string.Empty;
     dynamic output = null;
     if (accessToken != null)
     {
         fb.AccessToken = accessToken;
         dynamic profile = fb.Get("v2.5/me");
         output = fb.Get("v2.5/me/groups");
         foreach (var item in output["data"])
         {
             try
             {
                 Domain.Socioboard.Domain.AddFacebookGroup objAddFacebookGroup = new Domain.Socioboard.Domain.AddFacebookGroup();
                 objAddFacebookGroup.ProfileGroupId = item["id"].ToString();
                 objAddFacebookGroup.Name = item["name"].ToString();
                 objAddFacebookGroup.AccessToken = accessToken.ToString();
                 lstAddFacebookGroup.Add(objAddFacebookGroup);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
             }
         }
     }
     return new JavaScriptSerializer().Serialize(lstAddFacebookGroup);
 }
        public string GetFacebookGroups(string code)
        {
            string client_id = ConfigurationManager.AppSettings["ClientId"];
            string redirect_uri = ConfigurationManager.AppSettings["RedirectUrl"];
            string client_secret = ConfigurationManager.AppSettings["ClientSecretKey"];
            List<Domain.Socioboard.Domain.AddFacebookGroup> lstAddFacebookGroup = new List<Domain.Socioboard.Domain.AddFacebookGroup>();
            FacebookClient fb = new FacebookClient();
            string profileId = string.Empty;
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("client_id", client_id);
            parameters.Add("redirect_uri", redirect_uri);
            parameters.Add("client_secret", client_secret);
            parameters.Add("code", code);
            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;
            JsonObject fbaccess_token = (JsonObject)fb.Get("/oauth/access_token", parameters);
            string accessToken = fbaccess_token["access_token"].ToString();
            dynamic output = null;
            if (accessToken != null)
            {
                fb.AccessToken = accessToken;
                dynamic profile = fb.Get("v2.5/me");
                output = fb.Get("v2.5/me/groups");
                foreach (var item in output["data"])
                {
                    try
                    {
                        Domain.Socioboard.Domain.AddFacebookGroup objAddFacebookGroup = new Domain.Socioboard.Domain.AddFacebookGroup();
                        objAddFacebookGroup.ProfileGroupId = item["id"].ToString();
                        objAddFacebookGroup.Name = item["name"].ToString();

                        objAddFacebookGroup.AccessToken = accessToken.ToString();
                        objAddFacebookGroup.Email = profile["email"].ToString();
                        lstAddFacebookGroup.Add(objAddFacebookGroup);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                }
            }
            return new JavaScriptSerializer().Serialize(lstAddFacebookGroup);
        }