Beispiel #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"] = "";
                }
            }
        }