mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-12-29 18:04:42 +08:00
feat: 移除基础依赖库,升级公共组件,并适配 .NET 6.0
This commit is contained in:
@@ -38,7 +38,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Ads
|
||||
|
||||
if (request.FileHash == null)
|
||||
{
|
||||
request.FileHash = Security.MD5Utility.Hash(request.FileBytes ?? new byte[0]);
|
||||
request.FileHash = Utilities.MD5Utility.Hash(request.FileBytes ?? new byte[0]);
|
||||
}
|
||||
|
||||
string boundary = "--BOUNDARY--" + DateTimeOffset.Now.Ticks.ToString("x");
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Ads.Interceptors
|
||||
|
||||
string timestamp = DateTimeOffset.Now.ToLocalTime().ToUnixTimeSeconds().ToString();
|
||||
string nonce = Guid.NewGuid().ToString("N");
|
||||
string sign = Security.MD5Utility.Hash($"{_agencyId}{timestamp}{nonce}{_agencyApiKey}").ToLower();
|
||||
string sign = Utilities.MD5Utility.Hash($"{_agencyId}{timestamp}{nonce}{_agencyApiKey}").ToLower();
|
||||
string token = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{_agencyId},{timestamp},{nonce},{sign}"));
|
||||
|
||||
flurlCall.Request.RemoveQueryParam("agency_token");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net461; netstandard2.0; net5.0</TargetFrameworks>
|
||||
<TargetFrameworks>net461; netstandard2.0; net5.0; net6.0</TargetFrameworks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<NullableReferenceTypes>true</NullableReferenceTypes>
|
||||
@@ -27,11 +27,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SKIT.FlurlHttpClient.Wechat\SKIT.FlurlHttpClient.Wechat.csproj" />
|
||||
<PackageReference Include="SKIT.FlurlHttpClient.Common" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
39
src/SKIT.FlurlHttpClient.Wechat.Ads/Utilities/MD5Utility.cs
Normal file
39
src/SKIT.FlurlHttpClient.Wechat.Ads/Utilities/MD5Utility.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Ads.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// MD5 算法工具类。
|
||||
/// </summary>
|
||||
public static class MD5Utility
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取信息摘要。
|
||||
/// </summary>
|
||||
/// <param name="bytes">信息字节数组。</param>
|
||||
/// <returns>信息摘要。</returns>
|
||||
public static string Hash(byte[] bytes)
|
||||
{
|
||||
if (bytes == null) throw new ArgumentNullException(nameof(bytes));
|
||||
|
||||
using MD5 md5 = MD5.Create();
|
||||
byte[] hashBytes = md5.ComputeHash(bytes);
|
||||
return BitConverter.ToString(hashBytes).Replace("-", "");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取信息摘要。
|
||||
/// </summary>
|
||||
/// <param name="message">文本信息。</param>
|
||||
/// <returns>信息摘要。</returns>
|
||||
public static string Hash(string message)
|
||||
{
|
||||
if (message == null) throw new ArgumentNullException(nameof(message));
|
||||
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(message);
|
||||
return Hash(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Flurl.Http;
|
||||
using Flurl.Http.Configuration;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Ads
|
||||
{
|
||||
/// <summary>
|
||||
/// 一个微信广告平台 API HTTP 客户端。
|
||||
/// </summary>
|
||||
public class WechatAdsClient : CommonClientBase, IWechatClient
|
||||
public class WechatAdsClient : CommonClientBase, ICommonClient
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取当前客户端使用的微信广告平台凭证。
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/// <summary>
|
||||
/// 微信广告平台 API 请求的基类。
|
||||
/// </summary>
|
||||
public abstract class WechatAdsRequest : IWechatRequest
|
||||
public abstract class WechatAdsRequest : ICommonRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置请求超时时间(单位:毫秒)。如果不指定将使用构造 <see cref="WechatAdsClient"/> 时的 <see cref="WechatAdsClientOptions.Timeout"/> 参数,这在需要指定特定耗时请求(比如上传或下载文件)的超时时间时很有用。
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Ads
|
||||
/// <summary>
|
||||
/// 微信广告平台 API 响应的基类。
|
||||
/// </summary>
|
||||
public abstract class WechatAdsResponse : IWechatResponse
|
||||
public abstract class WechatAdsResponse : ICommonResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取原始的 HTTP 响应状态码。
|
||||
|
||||
Reference in New Issue
Block a user