mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-07-16 16:50:43 +08:00
feat(wxapi): 新增人脸核身相关接口
This commit is contained in:
parent
b8b1d2aec4
commit
5d7f027daf
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@ -48,5 +48,64 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CityServiceGetServicePathResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
#region Face
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cityservice/face/identify/getuseridkey 接口。</para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CityServiceFaceIdentifyGetUserIdKeyResponse> ExecuteCityServiceFaceIdentifyGetUserIdKeyAsync(this WechatApiClient client, Models.CityServiceFaceIdentifyGetUserIdKeyRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(request, HttpMethod.Post, "cityservice", "face", "identify", "getuseridkey")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CityServiceFaceIdentifyGetUserIdKeyResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cityservice/face/identify/getinfo 接口。</para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CityServiceFaceIdentifyGetInfoResponse> ExecuteCityServiceFaceIdentifyGetInfoAsync(this WechatApiClient client, Models.CityServiceFaceIdentifyGetInfoRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(request, HttpMethod.Post, "cityservice", "face", "identify", "getinfo")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CityServiceFaceIdentifyGetInfoResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cityservice/face/identify/getimage 接口。</para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CityServiceFaceIdentifyGetImageResponse> ExecuteCityServiceFaceIdentifyGetImageAsync(this WechatApiClient client, Models.CityServiceFaceIdentifyGetImageRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(request, HttpMethod.Post, "cityservice", "face", "identify", "getimage")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CityServiceFaceIdentifyGetImageResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cityservice/face/identify/getimage 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CityServiceFaceIdentifyGetImageRequest : WechatApiRequest, IInferable<CityServiceFaceIdentifyGetImageRequest, CityServiceFaceIdentifyGetImageResponse>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置人脸验证结果加密数据。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("verify_result")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("verify_result")]
|
||||
public string VerifyResult { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cityservice/face/identify/getimage 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CityServiceFaceIdentifyGetImageResponse : WechatApiResponse
|
||||
{
|
||||
public override bool IsSuccessful()
|
||||
{
|
||||
return base.IsSuccessful() && RawBytes?.Length > 0 && RawHeaders.ContainsKey("Content-Disposition");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cityservice/face/identify/getinfo 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CityServiceFaceIdentifyGetInfoRequest : WechatApiRequest, IInferable<CityServiceFaceIdentifyGetInfoRequest, CityServiceFaceIdentifyGetInfoResponse>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置人脸验证结果加密数据。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("verify_result")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("verify_result")]
|
||||
public string VerifyResult { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cityservice/face/identify/getinfo 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CityServiceFaceIdentifyGetInfoResponse : WechatApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置认证结果。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("identify_ret")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("identify_ret")]
|
||||
public int IdentifyResult { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置认证时间戳。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("identify_time")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("identify_time")]
|
||||
public long IdentifyTimestamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置验证数据。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("validate_data")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("validate_data")]
|
||||
public string? ValidateData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户的 OpenId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("openid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("openid")]
|
||||
public string? OpenId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置后台交互凭证。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("user_id_key")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("user_id_key")]
|
||||
public string? UserIdKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置姓名的 MD5 值。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("name_utf8_md5")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("name_utf8_md5")]
|
||||
public string? NameMd5 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置身份证号码的 MD5 值。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("id_card_number_md5")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("id_card_number_md5")]
|
||||
public string? IdCardNumberMd5 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置认证结束时间戳。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("finish_time")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("finish_time")]
|
||||
public long? FinishTimestamp { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cityservice/face/identify/getuseridkey 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CityServiceFaceIdentifyGetUserIdKeyRequest : WechatApiRequest, IInferable<CityServiceFaceIdentifyGetUserIdKeyRequest, CityServiceFaceIdentifyGetUserIdKeyResponse>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置姓名。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("name")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("name")]
|
||||
public string CityName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置身份证号码。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("id_card_number")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("id_card_number")]
|
||||
public string IdCardNumber { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cityservice/face/identify/getuseridkey 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CityServiceFaceIdentifyGetUserIdKeyResponse : WechatApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置后台交互凭证。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("user_id_key")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("user_id_key")]
|
||||
public string UserIdKey { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置后台交互凭证有效期(单位:秒)。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("expires_in")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("expires_in")]
|
||||
public int ExpiresIn { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"verify_result": ""
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"verify_result": ""
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"identify_ret": 0,
|
||||
"identify_time": 1486350357,
|
||||
"validate_data": "8593"
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "张三",
|
||||
"id_card_number": "452344xxxxxxxxxxxxx234"
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"user_id_key": "id_key_xxxx",
|
||||
"expires_in": 3600
|
||||
}
|
Loading…
Reference in New Issue
Block a user