//public User_RecommendModel(int page) //{ //} public static User_RecommendModel Get(int page) { User_RecommendModel rtnModel = new User_RecommendModel(); string url = $"https://api.live.bilibili.com/room/v1/room/get_user_recommend?page={page}"; string[] headers = { "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0", "Referer: https://live.bilibili.com/all?visit_id=b697kwgsxi80", "Origin: https://live.bilibili.com" }; string jsonData = HttpAide.HttpGet(url: url, headers: headers); try { User_RecommendModel model = JsonConvert.DeserializeObject <User_RecommendModel>(jsonData); if (model.code == 0) { rtnModel.code = model.code; rtnModel.msg = model.msg; rtnModel.message = model.message; rtnModel.data = model.data; } } catch (Exception ex) { rtnModel.code = -1; } return(rtnModel); }
/// <summary> /// 先进入直播间 /// </summary> /// <param name="roomId"></param> /// <returns></returns> public bool EntryLiveRoom_PCWeb(int roomId) { bool isSuccess = false; string url = "https://api.live.bilibili.com/room/v1/Room/room_entry_action"; string postData = ""; Room_Entry_Action_RequestModel requestModel = new Room_Entry_Action_RequestModel { room_id = roomId, csrf = _cookie.bili_jct, csrf_token = _cookie.bili_jct, }; string postDataStr = $"room_id={requestModel.room_id}&platform={requestModel.platform}&csrf_token={requestModel.csrf_token}&csrf={requestModel.csrf}&visit_id="; try { string resData = HttpAide.HttpPost(url: url, postDataStr: postDataStr, headers: _requestHeaders_PCWeb.ToArray()); isSuccess = true; } catch (Exception ex) { } return(isSuccess); }
public void Join_SmallTv(int smallTvId, int roomId) { string url = "https://api.live.bilibili.com/xlive/lottery-interface/v3/guard/join"; SmallTv_Join_RequestModel requestModel = new SmallTv_Join_RequestModel { roomid = roomId, id = smallTvId, csrf = _cookie.bili_jct, csrf_token = _cookie.bili_jct, }; string postDataStr = $"id={requestModel.id}&roomid={requestModel.roomid}&type={requestModel.type}&csrf_token={requestModel.csrf_token}&csrf={requestModel.csrf}A&visit_id="; try { string jsonData = HttpAide.HttpPost(url: url, postDataStr: postDataStr, headers: _requestHeaders_PCWeb.ToArray()); SmallTv_Join_ResponseModel jsonModel = JsonConvert.DeserializeObject <SmallTv_Join_ResponseModel>(jsonData); if (jsonModel.code == 0) { Console.ForegroundColor = ConsoleColor.Blue; int day = (int)(DateTimeHelper.ToDateTime10(jsonModel.data.award_ex_time) - DateTime.Now).TotalDays + 1; Console.WriteLine($"{DateTime.Now.ToString()}--在房间 {roomId} 获奖--来自 小电视飞船: {jsonModel.data.award_name} × {jsonModel.data.award_num} 有效时间: {day}天"); Console.ForegroundColor = ConsoleColor.White; } else { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine($"{DateTime.Now.ToString()}--在房间 {roomId} --来自 小电视: {jsonModel.message}"); Console.ForegroundColor = ConsoleColor.White; } } catch (Exception ex) { } }
private static void ZhidaoSignIn(HttpContext context) { string result = string.Empty; #region 读取 cookie string cookiePath = AppDomain.CurrentDomain.BaseDirectory + "cookie.txt"; string cookie = File.ReadAllText(cookiePath); if (string.IsNullOrEmpty(cookie)) { result = "请检查 cookie.txt"; context.Response.Write(result); return; } #endregion #region 获取 BDUSS string bduss = string.Empty; if (cookie.Contains("BDUSS")) { string pattern = "BDUSS=([a-zA-Z0-9-]+);?"; Match match = Regex.Match(cookie, pattern); if (match.Success) { bduss = match.Groups[1].Value; } else { result = "请检查 cookie.txt"; } } else { bduss = cookie; } #endregion #region 发送请求,进行签到 if (!string.IsNullOrEmpty(bduss)) { int cornPos = context.Request.Url.AbsoluteUri.LastIndexOf("/corn.ashx", StringComparison.OrdinalIgnoreCase); // 去掉末尾的 /corn.ashx 再拼接上 /Api/SignIn.ashx?bduss= string url = context.Request.Url.AbsoluteUri.Substring(0, cornPos) + "/Api/SignIn.ashx?bduss=" + bduss; string jsonStr = HttpAide.HttpGet(url: url); dynamic jsonObj = JsonConvert.DeserializeObject <dynamic>(jsonStr); if (Common.IsPropertyExist(jsonObj, "code") && jsonObj.code.ToString() == "1") { result = "签到成功, 签到时间:" + jsonObj.signTime.ToString(); } else { result = "签到失败"; } } #endregion context.Response.Write(result); }
public void LotteryCheck(int roomId) { string url = $"https://api.live.bilibili.com/xlive/lottery-interface/v1/lottery/Check?roomid={roomId}"; string jsonData = HttpAide.HttpGet(url: url, headers: _requestHeaders_PCWeb.ToArray()); LotteryCheck_ResponseModel jsonModel = JsonConvert.DeserializeObject <LotteryCheck_ResponseModel>(jsonData); if (jsonModel != null && jsonModel.code == 0) { // 舰队 var guards = jsonModel.data.guard; foreach (var guard in guards) { new Thread(() => { Join_Guard(guard.id, roomId); }) { IsBackground = true }.Start(); } // 礼物: 1.小电视飞船 var gifts = jsonModel.data.gift; foreach (var gift in gifts) { switch (gift.type) { case "small_tv": // 小电视 int max_wait = gift.time - 10; int try_wait = new Random().Next(gift.time_wait, max_wait); new Thread(() => { try { Thread.Sleep(try_wait * 1000); } catch (Exception ex) { } Join_SmallTv(gift.raffleId, roomId); }) { IsBackground = true }.Start(); break; default: break; } } } }
/// <summary> /// 效验票据有效性 /// </summary> /// <param name="ticket">验证码客户端验证回调的票据</param> /// <param name="userId">用户会话唯一标识</param> /// <param name="userIp">提交验证的用户的IP地址(eg: 10.127.10.2)</param> /// <returns></returns> public TicketVerifyResponseModel Verify(string ticket, string userId, string userIp) { TicketVerifyResponseModel ticketVerifyModel = new TicketVerifyResponseModel { code = -1, message = "效验失败" }; string reqJsonStr = JsonHelper.Serialize(new { appId = _options.AppId, appSecret = _options.AppSecret, ticket, userId, userIp }); //string reqStr = $"appId={_options.AppId}&appSecret={_options.AppSecret}&ticket={ticket}&userId={userId}&userIp={userIp}"; // 效验票据 try { string[] headers = { "Content-Type: application/json" }; //string[] headers = { "Content-Type: application/x-www-form-urlencoded" }; string resJsonStr = HttpAide.HttpPost(_options.TicketVerifyUrl, postDataStr: reqJsonStr, headers: headers); //string resJsonStr = HttpAide.HttpPost(_options.TicketVerifyUrl, postDataStr: reqStr); ticketVerifyModel = JsonHelper.Deserialize <TicketVerifyResponseModel>(resJsonStr); } catch (Exception ex) { } return(ticketVerifyModel); }