Ejemplo n.º 1
0
        protected void Sina()
        {
            //?Type=sina&code=9d9dbbd8596b730993e5db69a4771f68
            //产生一次性的code,依此获取Token与用户信息
            M_Third_Info sinaInfo = thirdBll.SelModelByName("Sina");
            string       code     = Request.QueryString["code"];

            if (string.IsNullOrEmpty(code))
            {
                function.WriteErrMsg("未传指定参数");
            }
            //SinaWeiboClient client = new SinaWeiboClient(sinaInfo.Key, sinaInfo.Secret, sinaInfo.CallBackUrl);
            //string token = client.GetAccessTokenByCode(code);
            SinaHelper sinaBll = new SinaHelper(null);
            string     openid  = sinaBll.GetUidByCode(code);

            if (HasExist(openid, "sina"))//用户已存在,直接登录
            {
                Response.Redirect(targetUrl);
            }
            else
            {
                //否则选填信息后登录
                if (ForAudit_Hid.Value == "1")
                {
                    AutoUser("sina", openid);
                }
                else
                {
                    Sina_OpenID_Hid.Value          = openid;
                    Sina_div.Attributes["display"] = "";
                }
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //string appid = "wx64dcf57278caa037";
            //string redirect_uri = "http://www.zljdsc.com/test/WxLogin.aspx";
            //string secret = "71c21ab790c34c05e1290a26ff025c70";
            M_Third_Info wxInfo = thirdBll.SelModelByName("wechat");
            string       state  = "";

            if (string.IsNullOrEmpty(Request.QueryString["code"]))//微信登录操作
            {
                state = function.GetRandomString(8).ToLower();
                Session.Add("wx_state", state);
                string url = "https://open.weixin.qq.com/connect/qrconnect?appid=" + wxInfo.ID + "&redirect_uri=" + HttpUtility.UrlEncode(wxInfo.CallBackUrl) + "&response_type=code&scope=snsapi_login&state=" + state + "#wechat_redirect";
                Response.Redirect(url);
            }
            else//登录返回操作
            {
                //检测state参数是否匹配
                if (Session["wx_state"] == null || !Session["wx_state"].Equals(Request.QueryString["state"]))
                {
                    function.WriteErrMsg("参数错误!");
                }
                Session["wx_state"] = null;
                string  url     = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + wxInfo.ID + "&secret=" + wxInfo.Secret + "&code=" + Request.QueryString["code"] + "&grant_type=authorization_code";
                JObject wxinfo  = GetWxInfo(url);
                Appinfo infomod = AppBll.SelModelByOpenID(wxinfo["openid"].ToString(), "wechat");
                if (infomod == null)//新用户注册
                {
                    infomod = GetNewUser(wxinfo);
                }
                M_UserInfo mu = buser.SelReturnModel(infomod.UserID);
                buser.SetLoginState(mu);
                Response.Redirect("/User");
            }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //int uid = Convert.ToInt32(Request.QueryString["state"]);
                M_UserInfo   mu       = buser.GetLogin();//注意域名不要子域名跳过来
                M_User_Token tokenMod = tokenbll.SelModelByUid(mu.UserID);
                if (tokenMod == null)
                {
                    tokenMod = new M_User_Token();
                }
                switch (Request.QueryString["s"])
                {
                case "qq":    //使用JS SDK
                    break;

                default:    //Sina
                    string code = Request.QueryString["code"];
                    if (!string.IsNullOrEmpty(code))
                    {
                        M_Third_Info appmod  = thirdBll.SelModelByName("Sina");
                        SinaHelper   sinaBll = new SinaHelper(null);
                        tokenMod.uid       = mu.UserID;
                        tokenMod.SinaToken = sinaBll.GetTokenByCode(code);
                        tokenbll.InsertORUpdate(tokenMod);
                    }
                    Response.Redirect("/Plat/UpCenter.aspx?Set=1");
                    break;
                }
            }
        }
Ejemplo n.º 4
0
 //--------
 protected void QQ()
 {
     //?Type=QQ&#access_token=FB82968B4FC03BCB39FB917375D9BB51&expires_in=7776000
     thirdMod         = thirdBll.SelModelByName("QQ");
     PlatConfig.QQKey = thirdMod.ID;//底层是使用QQKey,将其传入
     QQ_Div.Visible   = true;
     Script_Lit.Text  = "<script src=\"http://qzonestyle.gtimg.cn/qzone/openapi/qc_loader.js\" data-appid=\"" + thirdMod.ID + "\" data-callback=\"true\" charset=\"utf-8\"></script>";
     function.Script(this, "QQBind();");
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 更新缓存中的XML信息,最后再由xml负责写入(需要更多则调用模型)
        /// </summary>
        public void UpdateToXml(XmlDocument xmlDoc, string dom, string key, string secret, string callbackUrl = "")
        {
            M_Third_Info model = new M_Third_Info();

            model.dom         = dom;
            model.Key         = key;
            model.Secret      = secret;
            model.CallBackUrl = callbackUrl;
            UpdateToXml(xmlDoc, model);
        }
Ejemplo n.º 6
0
        protected void bindVibo_B_Click(object sender, EventArgs e)
        {
            M_Third_Info appmod   = thirdBll.SelModelByName("Sina");
            M_User_Token tokenMod = tokenbll.SelModelByUid(buser.GetLogin().UserID);

            if (tokenMod == null)
            {
                tokenMod = new M_User_Token();
            }
            SinaHelper sinaBll = new SinaHelper(tokenMod.SinaToken);

            Response.Redirect(sinaBll.GetAuthUrl());
        }
Ejemplo n.º 7
0
        public void UpdateToXml(XmlDocument xmlDoc, M_Third_Info model)
        {
            //先检测是否存在,如果不存在则新建,存在则更新
            XmlNode node = xmlDoc.SelectSingleNode("//SuppliersList/" + model.dom);

            //if (node == null)
            //{
            //    XmlNode node = new XmlNode();
            //    node.Attributes.add
            //}
            if (node != null)
            {
                //node.Attributes["ID"].Value = model.ID.Trim();
                node.Attributes["Key"].Value    = model.Key.Trim();
                node.Attributes["Secret"].Value = model.Secret.Trim();
                //node.Attributes["CallBackUrl"].Value = model.CallBackUrl.Trim();
                //node.Attributes["Enable"].Value = (model.Enabled ? 1 : 0).ToString();
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 根据节点名称选元素
        /// </summary>
        public M_Third_Info SelModelByName(string dom)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(xmlPath);
            XmlNode      node  = xmlDoc.SelectSingleNode("//SuppliersList/" + dom);
            M_Third_Info model = new M_Third_Info();

            if (node != null)
            {
                model.dom = dom;
                model     = model.GetModelFrom(node);
            }
            else
            {
                model = null;
            }
            return(model);
        }
Ejemplo n.º 9
0
        //QQ APPID=Key,APPKey=Secret
        //Key:一串数字,Secret:一串字母
        //所有的存值都为 key和secret
        protected void Page_Load(object sender, EventArgs e)
        {
            B_Admin.IsSuperManage();
            if (!IsPostBack)
            {
                XmlDocument Xml = thirdBll.GetXmlDoc();
                //-------新浪
                {
                    M_Third_Info model = thirdBll.SelModelByName("Sina");
                    if (model != null)
                    {
                        ASina.Value             = PlatConfig.SinaKey;
                        SSina.Value             = PlatConfig.SinaSecret;
                        SSinaURL.Value          = PlatConfig.SinaCallBack;
                        Sina_Enable_Chk.Checked = model.Enabled;
                    }
                }
                //-------QQ
                {
                    M_Third_Info model = thirdBll.SelModelByName("QQ");
                    if (model != null)
                    {
                        QQ_Login_APPID_T.Value    = model.Key;
                        QQ_Login_Key_T.Value      = model.Secret;
                        QQ_Login_CallBack_T.Value = model.CallBackUrl;
                        QQ_Enable_Chk.Checked     = model.Enabled;
                    }
                }
                //-------微信
                {
                    M_Third_Info model = thirdBll.SelModelByName("wechat");
                    if (model != null)
                    {
                        WeChat_APPID_T.Text       = model.Key;
                        WeChat_Secret_T.Text      = model.Secret;
                        WeChat_URL_T.Text         = model.CallBackUrl;
                        Wechat_Enable_Chk.Checked = model.Enabled;
                    }
                }
                //-------百度
                {
                    M_Third_Info model = thirdBll.SelModelByName("Baidu");
                    if (model != null)
                    {
                        ABaidu.Value             = model.Key;
                        SBaidu.Value             = model.Secret;
                        UBaidu.Value             = model.CallBackUrl;
                        Baidu_Enable_Chk.Checked = model.Enabled;
                    }
                }
                //-------开心
                //{
                //    M_Third_Info model = thirdBll.SelModelByName("Kaixin");
                //    if (model != null)
                //    {
                //        AKaixin.Value = model.Key;
                //        SKaixin.Value = model.Secret;
                //        SKaixiuUrl.Value = model.CallBackUrl;
                //    }
                //}
                //-------搜狐畅言
                //XApp = Xml.SelectSingleNode("SuppliersList/SohuChat");
                //chat_AppIDT.Value = XApp.Attributes["Key"].Value;
                //chat_AppKeyT.Value = XApp.Attributes["Secret"].Value;
                //CkSohuChat.Checked = XApp.Attributes["Enable"].Value == "1" ? true : false;
                //-------百度翻译
                {
                    M_Third_Info model = thirdBll.SelModelByName("BaiduTrans");
                    if (model != null)
                    {
                        Baidu_Translate_Key_T.Text    = model.Key;
                        Baidu_Translate_Secret_T.Text = model.Secret;
                    }
                }
                //-------飞印打印机
                {
                    M_Third_Info model = thirdBll.SelModelByName("printer");
                    if (model != null)
                    {
                        Printer_Key_T.Text    = model.Key;    //商户号
                        Printer_Secret_T.Text = model.Secret; //Secret
                    }
                }
                //-------飞印打印机
                //XApp = Xml.SelectSingleNode("SuppliersList/BaiduTrans");
                //BaiduKey_T.Text = XApp.Attributes["Key"].Value;
                //BaiduAppID_T.Text = XApp.Attributes["AppID"].Value;
                //Sina_Blog_Key_T.Text = PlatConfig.SinaKey;
                //Sina_Blog_Secret_T.Text = PlatConfig.SinaSecret;
                //Sina_Blog_CallBack_T.Text = PlatConfig.SinaCallBack;
                QQ_Blog_Key_T.Text      = PlatConfig.QQKey;
                QQ_Blog_CallBack_T.Text = PlatConfig.QQCallBack;

                Call.SetBreadCrumb(Master, "<li><a href='" + CustomerPageAction.customPath2 + "Main.aspx'>" + Resources.L.工作台 + "</a></li><li><a href='" + CustomerPageAction.customPath2 + "user/UserManage.aspx'>" + Resources.L.用户管理 + "</a></li><li><a href='" + CustomerPageAction.customPath2 + "user/UserManage.aspx'>" + Resources.L.会员管理 + "</a></li><li>" + Resources.L.APP社会化登录 + "</li>" + Call.GetHelp(39));
            }
        }