From 3ec785f93ab3e47a0a9b7914c820491820ed3700 Mon Sep 17 00:00:00 2001 From: Executor Date: Sun, 23 Apr 2023 10:07:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=87=B31.0.3=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=9C=89=E6=97=B6=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=B8=BB=E6=92=AD=E5=9F=BA=E6=9C=AC=E4=BF=A1=E6=81=AF=E5=AF=BC?= =?UTF-8?q?=E8=87=B4toast=E6=97=A0=E6=B3=95=E5=BC=B9=E5=87=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20=E6=9B=B4=E6=96=B0nuget=E5=8C=85=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E7=89=88=E6=9C=AC=20=E6=B7=BB=E5=8A=A0=E5=AF=B9.net?= =?UTF-8?q?=207.0=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Directory.Build.props | 24 +++++++++---------- .../Apis/BiliApis.GetUserInfo.cs | 14 +++++------ .../BililiveNotification.csproj | 19 ++++++++++----- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 2520153..fa2aaed 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,15 +1,15 @@ - - net6.0-windows10.0.17763.0;net5.0-windows10.0.17763.0;netframework461-windows10.0.17763.0 - 9.0 - enable - true - true - true + + net7.0-windows10.0.17763.0;net6.0-windows10.0.17763.0;net5.0-windows10.0.17763.0;netframework461-windows10.0.17763.0 + 9.0 + enable + true + true + true - 1.0.2.0 - 1.0.2.0 - 1.0.2.0 - 1.0.2.0 - + 1.0.3.0 + 1.0.3.0 + 1.0.3.0 + 1.0.3.0 + diff --git a/src/BililiveNotification/Apis/BiliApis.GetUserInfo.cs b/src/BililiveNotification/Apis/BiliApis.GetUserInfo.cs index 7a60525..80be26c 100644 --- a/src/BililiveNotification/Apis/BiliApis.GetUserInfo.cs +++ b/src/BililiveNotification/Apis/BiliApis.GetUserInfo.cs @@ -1,4 +1,4 @@ -using BililiveNotification.Models; +using BililiveNotification.Models; using Executorlibs.Shared.Exceptions; using Executorlibs.Shared.Extensions; using System; @@ -13,18 +13,18 @@ public static partial class BiliApis { public static async Task GetUserInfoAsync(HttpClient client, int userId, CancellationToken token = default) { - HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, $"https://api.bilibili.com/x/space/acc/info?mid={userId}&jsonp=jsonp"); + HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, $"https://api.bilibili.com/x/web-interface/card?mid={userId}"); req.Headers.Accept.ParseAdd("*/*"); - req.Headers.Add("Origin", "https://live.bilibili.com"); - req.Headers.Referrer = new Uri("https://live.bilibili.com/"); - using JsonDocument j = await client.SendAsync(req, HttpCompletionOption.ResponseHeadersRead, token).GetJsonAsync(token); + req.Headers.Add("Origin", "https://www.bilibili.com"); + req.Headers.Referrer = new Uri("https://www.bilibili.com/"); + using JsonDocument j = await client.SendAsync(req, token).GetJsonAsync(token); JsonElement root = j.RootElement; if (root.GetProperty("code").GetInt32() != 0) { throw new UnknownResponseException(in root); } - JsonElement data = root.GetProperty("data"); - return new UserInfo(data.GetProperty("name").GetString()!, userId, data.GetProperty("face").GetString()!); + JsonElement card = root.GetProperty("data").GetProperty("card"); + return new UserInfo(card.GetProperty("name").GetString()!, userId, card.GetProperty("face").GetString()!); } } } diff --git a/src/BililiveNotification/BililiveNotification.csproj b/src/BililiveNotification/BililiveNotification.csproj index 2db6165..f7ef355 100644 --- a/src/BililiveNotification/BililiveNotification.csproj +++ b/src/BililiveNotification/BililiveNotification.csproj @@ -10,15 +10,22 @@ - - + + + + + + + + + - - - - + + + +