Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Session["X"] = "121.459441";
                Session["Y"] = "31.224461";
                List <MDSearch> list = mss.GetAllProvince();

                DataTable dt2 = ListToDataTable(list);

                DropDownList1.Items.Clear();
                DropDownList1.Items.Add(new ListItem("请选择省份"));
                foreach (DataRow dr in dt2.Rows)
                {
                    DropDownList1.Items.Add(new ListItem(dr["Province"].ToString()));
                }
                try
                {
                    if (Request.QueryString["code"] != null)
                    {
                        try
                        {
                            string url   = string.Format(@"https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + GetAppid(AppConfig.FWHOriginalID) + "&secret=" + GetSecret(AppConfig.FWHOriginalID) + "&code={0}&grant_type=authorization_code", Request.QueryString["code"].ToString());
                            string token = PostRequest(url);
                            if (token.Contains("7200"))
                            {
                                string[] b = token.Split('\"');
                                Session["FromUserName"] = b[13];
                                Session["ToUserName"]   = GetAppid(AppConfig.FWHOriginalID);
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
                catch (Exception)
                {
                }
            }

            try
            {
                if (!IsPostBack)
                {
                    PageLoad();
                }
            }
            catch (Exception)
            {
            }
        }