mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-24 04:53:46 +08:00
feat(wxapi): 新增小程序重置登录态接口
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
using System;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /wxa/checksession 接口的请求。</para>
|
||||
@@ -21,10 +23,27 @@
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户登录态签名的哈希方法。
|
||||
/// <para>默认值:hmac_sha256</para>
|
||||
/// <para>默认值:"hmac_sha256"</para>
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public string SignMethod { get; set; } = "hmac_sha256";
|
||||
|
||||
public void SetSignatureBySessionKey(string sessionKey, string signMethod = "hmac_sha256")
|
||||
{
|
||||
if (sessionKey is null) throw new ArgumentNullException(nameof(sessionKey));
|
||||
if (signMethod is null) throw new ArgumentNullException(nameof(signMethod));
|
||||
|
||||
switch (signMethod)
|
||||
{
|
||||
case "hmac_sha256":
|
||||
Signature = Utilities.HMACUtility.HashWithSHA256(sessionKey, string.Empty).Value!.ToLower();
|
||||
SignMethod = signMethod;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /wxa/resetusersessionkey 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class WxaResetUserSessionKeyRequest : WechatApiRequest, IInferable<WxaResetUserSessionKeyRequest, WxaResetUserSessionKeyResponse>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置用户唯一标识。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public string OpenId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户登录态签名。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public string Signature { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户登录态签名的哈希方法。
|
||||
/// <para>默认值:"hmac_sha256"</para>
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public string SignMethod { get; set; } = "hmac_sha256";
|
||||
|
||||
public void SetSignatureBySessionKey(string sessionKey, string signMethod = "hmac_sha256")
|
||||
{
|
||||
if (sessionKey is null) throw new ArgumentNullException(nameof(sessionKey));
|
||||
if (signMethod is null) throw new ArgumentNullException(nameof(signMethod));
|
||||
|
||||
switch (signMethod)
|
||||
{
|
||||
case "hmac_sha256":
|
||||
Signature = Utilities.HMACUtility.HashWithSHA256(sessionKey, string.Empty).Value!.ToLower();
|
||||
SignMethod = signMethod;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /wxa/resetusersessionkey 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class WxaResetUserSessionKeyResponse : WechatApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置用户唯一标识。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("openid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("openid")]
|
||||
public string OpenId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置重置后的会话密钥。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("session_key")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("session_key")]
|
||||
public string SessionKey { get; set; } = default!;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user