mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-04-05 17:37:54 +08:00
feat(wxapi): 新增换取用户手机号相关接口
This commit is contained in:
parent
8b1b07d8c0
commit
6d17a67875
@ -35,7 +35,6 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
return await client.SendRequestWithJsonAsync<Models.WxaBusinessGetPayForOrderResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /wxa/business/checkencryptedmsg 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/user-info/auth.checkEncryptedData.html </para>
|
||||
@ -57,6 +56,27 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
return await client.SendRequestWithJsonAsync<Models.WxaBusinessCheckEncryptedMessageResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /wxa/business/getuserphonenumber 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/phonenumber/phonenumber.getPhoneNumber.html </para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/minigame/dev/api-backend/open-api/phonenumber/phonenumber.getPhoneNumber.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.WxaBusinessGetUserPhoneNumberResponse> ExecuteWxaBusinessGetUserPhoneNumberAsync(this WechatApiClient client, Models.WxaBusinessGetUserPhoneNumberRequest 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, "wxa", "business", "getuserphonenumber")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.WxaBusinessGetUserPhoneNumberResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
#region GameMatch
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /wxa/business/gamematch/creatematchrule 接口。</para>
|
||||
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /wxa/business/getuserphonenumber 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class WxaBusinessGetUserPhoneNumberRequest : WechatApiRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置手机号获取凭证。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("code")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("code")]
|
||||
public string Code { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /wxa/business/getuserphonenumber 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class WxaBusinessGetUserPhoneNumberResponse : WechatApiResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class PhoneInfo
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Watermark
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置小程序 AppId
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("appid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("appid")]
|
||||
public string AppId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户获取手机号操作的时间戳。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("timestamp")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("timestamp")]
|
||||
public long Timestamp { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户绑定的手机号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("phoneNumber")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("phoneNumber")]
|
||||
public string PhoneNumber { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置没有区号的手机号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("purePhoneNumber")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("purePhoneNumber")]
|
||||
public string PurePhoneNumber { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置区号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("countryCode")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("countryCode")]
|
||||
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.NumericalStringConverter))]
|
||||
public string CountryCode { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置数据水印。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("watermark")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("watermark")]
|
||||
public Types.Watermark Watermark { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户手机号信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("phone_info")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("phone_info")]
|
||||
public Types.PhoneInfo PhoneInfo { get; set; } = default!;
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"code": "e31968a7f94cc5ee25fafc2aef2773f0bb8c3937b22520eb8ee345274d00c144"
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"phone_info": {
|
||||
"phoneNumber": "xxxxxx",
|
||||
"purePhoneNumber": "xxxxxx",
|
||||
"countryCode": 86,
|
||||
"watermark": {
|
||||
"timestamp": 1637744274,
|
||||
"appid": "xxxx"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user