/// <summary> /// 修改简介 /// </summary> /// <param name="NewDesc">新简介文本</param> public void ChangeDesc(string NewDesc) { string str = Bas.PostHTTPBody("https://api.bilibili.com/x/member/web/sign/update", "user_sign=" + NewDesc + "&jsonp=jsonp&csrf=" + Csrf_Token, Cookies); if (!string.IsNullOrEmpty(str)) { JObject obj = JObject.Parse(str); if ((int)obj["code"] == 0) { MsgBoxPushHelper.RaisePushMsg("修改简介成功!"); return; } } MsgBoxPushHelper.RaisePushMsg("修改简介失败!" + str); }
/// <summary> /// 监视器回调 /// </summary> /// <param name="o">oauthKey</param> private void MonitorCallback(object o) { string oauthKey = o.ToString(); string str = Bas.PostHTTPBody("https://passport.bilibili.com/qrcode/getLoginInfo", "oauthKey=" + oauthKey + "&gourl=https%3A%2F%2Fwww.bilibili.com%2F", "", "https://passport.bilibili.com/login"); if (!string.IsNullOrEmpty(str)) { JObject obj = JObject.Parse(str); if (obj.Property("code") != null) { if ((int)obj["code"] == 0)//登陆成功 { //关闭监视器 Monitor.Change(Timeout.Infinite, Timeout.Infinite); Refresher.Change(Timeout.Infinite, Timeout.Infinite); string Querystring = Regex.Split(obj["data"]["url"].ToString(), "\\?")[1]; string[] KeyValuePair = Regex.Split(Querystring, "&"); string cookies = ""; for (int i = 0; i < KeyValuePair.Length - 1; i++) { cookies += KeyValuePair[i] + "; "; string[] tmp = Regex.Split(KeyValuePair[i], "="); switch (tmp[0]) { case "bili_jct": Bas.account.Csrf_Token = tmp[1]; break; case "DedeUserID": Bas.account.Uid = tmp[1]; break; default: break; } } cookies = cookies.Substring(0, cookies.Length - 2); DateTime expires = DateTime.Now.AddDays(29); Bas.account.Cookies = cookies; Bas.account.Expires = expires; Bas.account.Save(); Dispatcher.Invoke(delegate() { DialogResult = true; Close(); }); } } else { switch ((int)obj["data"]) { case -4: //未扫描 break; case -5: //已扫描 lbl_stauts.Dispatcher.Invoke(delegate() { lbl_stauts.Visibility = Visibility.Visible; }); break; case 0: //登陆成功 break; } } } }