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"] = ""; } } }
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; } } }
private void MyBind() { M_User_Plat upMod = B_User_Plat.GetLogin(); M_Plat_Comp compMod = compBll.SelReturnModel(upMod.CompID); Title_T.Text = compMod.CompName + "办公平台"; //--------------获取本月日程数据,并转为JSON,方便绑定 myplan_hid.Value = sdlBll.SelMonthToJson(DateTime.Now, upMod.UserID); //--------------平台 M_User_Token tokenMod = tokenBll.SelModelByUid(upMod.UserID); bool flag = false; if (tokenMod != null) { if (!string.IsNullOrWhiteSpace(tokenMod.SinaToken)) { sinaBll = new SinaHelper(tokenMod.SinaToken); sina_li.Visible = true; flag = true; if (!sinaBll.CheckToken())//Token有效 { sina_li.InnerHtml = sina_li.InnerHtml + "<span class='r_red'>(已失效)</span>"; sina_li.Attributes.Add("title", "点击重新绑定"); sina_li.Attributes.Add("onclick", "OpenWin(2);"); } } if (!string.IsNullOrWhiteSpace(tokenMod.QQToken)) { qqBll = new QQHelper(tokenMod.QQToken, tokenMod.QQOpenID); qqblog_li.Visible = true; flag = true; if (!qqBll.TokenIsValid()) { qqblog_li.InnerHtml = qqblog_li.InnerHtml + "<span class='r_red'>(已失效)</span>"; qqblog_li.Attributes.Add("title", "点击重新绑定"); qqblog_li.Attributes.Add("onclick", "OpenWin(2);"); } } } bloglist.Visible = flag; noplat_div.Visible = !flag; //----------- GroupRpt.DataSource = groupBll.SelGroupByAuth(upMod.UserID); GroupRpt.DataBind(); DataTable cateDT = barBll.SelBlogCate(upMod.CompID); if (cateDT.Rows.Count > 0) { Cate_RPT.DataSource = cateDT; Cate_RPT.DataBind(); } else { Cart_RPT_Empty.Visible = true; } EndDate_T.Text = DateTime.Now.AddDays(1).ToString("yyyy/MM/dd HH:mm"); UserInfo_Hid.Value = upMod.TrueName + ":" + upMod.UserFace + ":" + upMod.UserID; ////--最近的投票 //newvote_Rep.DataSource = (from t in dt.AsEnumerable() // where t.Field<int>("MsgType") == 2 // orderby t.Field<DateTime>("CDate") // select new { Title = t.Field<string>("Title"), CDate = t.Field<DateTime>("CDate"), UserFace = t.Field<string>("UserFace") }).Take(5); //newvote_Rep.DataBind(); }
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()); }
//新浪社会化登录(跳转链接) public void Login_Sina() { B_User_Token tokenBll = new B_User_Token(); M_User_Token tokenMod = tokenBll.SelModelByUid(buser.GetLogin().UserID); if (tokenMod != null)//已存有用户信息,则直接登录 { SinaHelper sinaBll = new SinaHelper(tokenMod.SinaToken); Response.Redirect(sinaBll.GetAuthUrl()); return; } else { SinaHelper sinaBll = new SinaHelper(""); Response.Redirect(sinaBll.GetAuthUrl()); return; } }
private void showViboIcons(int uid) { tokenMod = tokenbll.SelModelByUid(uid); if (tokenMod == null) { return; } if (!string.IsNullOrEmpty(tokenMod.SinaToken)) { SinaHelper sina = new SinaHelper(tokenMod.SinaToken); if (sina.CheckToken()) { JObject uinfo = sina.GetUserState(sina.GetUid()); sinaStatu_D.InnerText = "(已绑定)";//" + uinfo["screen_name"].ToString() + " sinaimg.Style.Add("color", "rgb(10, 164, 231)"); Sina_Btn.Text = "修改绑定"; } else { sinaStatu_D.InnerText = "(已过期)"; } } if (!string.IsNullOrEmpty(tokenMod.QQToken)) { QQHelper qqhelper = new QQHelper(tokenMod.QQToken, tokenMod.QQOpenID); if (qqhelper.TokenIsValid()) { QQStatus_Div.InnerText = "(已绑定:" + tokenMod.QQUName + ")"; qqimg.Style.Add("color", "rgb(10, 164, 231)"); QQSPan.InnerText = "修改绑定"; } else { QQStatus_Div.InnerText = "(已过期:" + tokenMod.QQUName + ")"; } } }
protected void Page_Load(object sender, EventArgs e) { #region AJAX请求 //正数为消息,负数为贴吧 if (function.isAjax()) { string action = Request["action"]; string result = ""; int id = DataConvert.CLng(Regex.Split(Request["value"] ?? "", ":::")[0]); //思路,信息都存在贴吧中,ID为负数 switch (action) { case "add": { string puremsg = ""; msgMod = FillMsg(Request.Form["MsgContent_T"], out puremsg); result = msgBll.Insert(msgMod).ToString(); #region 步至微博 if (!string.IsNullOrWhiteSpace(Request.Form["sync_chk"])) { puremsg = StringHelper.SubStr(puremsg, 140, ""); string sync = Request.Form["sync_chk"]; M_UserInfo mu = buser.GetLogin(); M_User_Token tokenMod = tokenBll.SelModelByUid(mu.UserID); if (tokenMod != null) { try { if (sync.Contains("qqblog") && !string.IsNullOrWhiteSpace(tokenMod.QQToken)) { qqBll = new QQHelper(tokenMod.QQToken, tokenMod.QQOpenID); if (!string.IsNullOrEmpty(msgMod.Attach)) { qqBll.AddBlog(puremsg, msgMod.Attach.Split('|')[0]); } else { qqBll.AddBlog(puremsg); } } if (sync.Contains("sina") && !string.IsNullOrWhiteSpace(tokenMod.SinaToken)) { sinaBll = new SinaHelper(tokenMod.SinaToken); string err = sinaBll.PostStatus(puremsg, (msgMod.Attach ?? "").Split('|')[0]); ZLLog.L(err); } } catch (Exception ex) { ZLLog.L("[" + sync + "]同步失败,用户[" + mu.UserName + "]原因:" + ex.Message); } } } #endregion } break; case "addvote": { msgMod = FillMsg(Request.Form["MsgContent_T"]); msgMod.MsgType = 2; msgMod.Title = HttpUtility.HtmlEncode(VoteTitle_T.Text); msgMod.VoteOP = Request.Form["VoteOption_T1"] + "," + Request.Form["VoteOption_T"]; //为Jquery验证 msgMod.VoteOP = HttpUtility.HtmlEncode(msgMod.VoteOP); msgMod.VoteResult = ""; msgMod.EndTime = DateTime.Parse(EndDate_T.Text); result = msgBll.Insert(msgMod).ToString(); } break; case "addarticle": //里面包含html|图片|附件,暂不同步微博 { string msg = Request.Form["msg"]; UEHelper ueHelper = new UEHelper(); msgMod = FillMsg(""); msgMod.MsgContent = msg; msgMod.MsgType = 3; msgMod.Title = ueHelper.GetSubTitle(msgMod.MsgContent); result = msgBll.Insert(msgMod).ToString(); } break; case "AddReply": case "AddReply2": if (id == 0) { throw new Exception("传入的ID不正确"); } result = PlatAJAX(); break; case "UserVote": result = PlatAJAX(); break; default: if (id == 0) { throw new Exception("信息ID不正确"); } if (id > 0) { result = PlatAJAX(); } else { result = BarAJAX(); } break; } Response.Write(result); Response.Flush(); Response.End(); } #endregion if (!IsPostBack) { MyBind(); } }