protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { ActiveURL = ConfigurationSettings.AppSettings["ActiveURL"]; if (Request["app_id"] != null) { appID = Request["app_id"].ToString(); } if (Request["code"] != null) { Dictionary<string, string> token = new Dictionary<string, string>(); //fetch secret key for app_id FacebookBizProcess fbBiz = new FacebookBizProcess(); appSecret = fbBiz.GetAppSecret(appID); token = GetAccessToken(Request["code"].ToString(), "manage_pages,publish_stream", ActiveURL + appID, appID, appSecret); //Get List of Pages FaceBook fb = new FaceBook(); string sPages = fb.GetPageAccessToken(token["access_token"].ToString()); SessionData.Config = fbBiz.GetAppConfiguration("", appID); string pagetab = string.Empty; DataColumn[] dcPage = new DataColumn[3]; dcPage[0] = new DataColumn("pid", System.Type.GetType("System.String")); dtPage.Columns.Add(dcPage[0]); dcPage[1] = new DataColumn("pname", System.Type.GetType("System.String")); dtPage.Columns.Add(dcPage[1]); dcPage[2] = new DataColumn("pacctoken", System.Type.GetType("System.String")); dtPage.Columns.Add(dcPage[2]); System.Web.Script.Serialization.JavaScriptSerializer _oJavaScriptSerializerJason = new System.Web.Script.Serialization.JavaScriptSerializer(); JObject objJason = JObject.Parse(sPages); foreach (var i in objJason["data"].Children()) { if ((i["category"].ToString().Replace("\"", "")) != "Application") { DataRow drPage = dtPage.NewRow(); drPage["pid"] = i["id"].ToString().Replace("\"", ""); drPage["pname"] = i["name"].ToString().Replace("\"", ""); drPage["pacctoken"] = i["access_token"].ToString().Replace("\"", ""); dtPage.Rows.Add(drPage); } } dsPage.Tables.Add(dtPage); //now bind all pages to drop down if (dtPage.Rows.Count > 0) { foreach (DataRow dr in dtPage.Rows) { ddlPageSelect.Items.Add(new ListItem(dr["pname"].ToString(), dr["pacctoken"].ToString())); } Cache["PageDetails"] = dtPage; ddlPageSelect.DataTextField = "pname"; ddlPageSelect.DataValueField = "pacctoken"; } else { pageSelect.Visible = false; noPageFound.Visible = true; lblNoPage.Text = "You are not admin of any pages"; } } } if (Request["Twitter"] != null) { bEnableTwitter = true; //litEnableTweet.Text = GetTwitterShareURL(); } } catch (Exception ex) { CommonUtility commUtil = new CommonUtility(); commUtil.SendErrorMail(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), SessionData.Customer.CustomerID); } }