| | |
| | | 微信小程序订阅消息通知 |
| | | </summary> |
| | | </member> |
| | | <member name="P:ApiTools.Core.WxmpSubscribMessageNotifyRequestQuery.Signature"> |
| | | <summary> |
| | | 签名 |
| | | </summary> |
| | | </member> |
| | | <member name="P:ApiTools.Core.WxmpSubscribMessageNotifyRequestQuery.Timestamp"> |
| | | <summary> |
| | | 时间戳 |
| | | </summary> |
| | | </member> |
| | | <member name="P:ApiTools.Core.WxmpSubscribMessageNotifyRequestQuery.Nonce"> |
| | | <summary> |
| | | 随机数 |
| | | </summary> |
| | | </member> |
| | | <member name="P:ApiTools.Core.WxmpSubscribMessageNotifyRequestQuery.Echostr"> |
| | | <summary> |
| | | 随机字符串 |
| | | </summary> |
| | | </member> |
| | | <member name="T:ApiTools.Core.GetWxmpSubscribMessageTemplatesQuery"> |
| | | <summary> |
| | | 查询微信小程序订阅消息模板 |
| | |
| | | 微信小程序配置 |
| | | </summary> |
| | | </member> |
| | | <member name="P:ApiTools.Core.WxmpOptions.SubscribMessage"> |
| | | <summary> |
| | | 订阅消息 |
| | | </summary> |
| | | </member> |
| | | <member name="P:ApiTools.Core.WxmpOptionsSubscribMessage.Token"> |
| | | <summary> |
| | | 令牌 |
| | | </summary> |
| | | </member> |
| | | <member name="P:ApiTools.Core.WxmpOptionsSubscribMessage.EncodingAESKey"> |
| | | <summary> |
| | | 消息加密密钥 |
| | | </summary> |
| | | </member> |
| | | <member name="P:ApiTools.Core.WxmpOptionsItem.Code"> |
| | | <summary> |
| | | 编号 |
| | |
| | | /// <summary> |
| | | /// 微信小程序订阅消息通知 |
| | | /// </summary> |
| | | [Resource([EnumResourceController.CommonServerWxmpUtils], Method = EnumResourceMethod.Post)] |
| | | [Resource([EnumResourceController.CommonServerWxmpUtils], Method = EnumResourceMethod.Get)] |
| | | public class WxmpSubscribMessageNotifyCommand : IRequest<bool> |
| | | { |
| | | |
| | | |
| | | public string ToUserName { get; set; } |
| | | public string FromUserName { get; set; } |
| | | public DateTime CreateTime { get; set; } |
| New file |
| | |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace ApiTools.Core |
| | | { |
| | | public class WxmpSubscribMessageNotifyRequestQuery |
| | | { |
| | | /// <summary> |
| | | /// 签名 |
| | | /// </summary> |
| | | [JsonProperty("signature")] |
| | | public string Signature { get; set; } |
| | | /// <summary> |
| | | /// 时间戳 |
| | | /// </summary> |
| | | [JsonProperty("timestamp")] |
| | | public string Timestamp { get; set; } |
| | | /// <summary> |
| | | /// 随机数 |
| | | /// </summary> |
| | | [JsonProperty("nonce")] |
| | | public string Nonce { get; set; } |
| | | /// <summary> |
| | | /// 随机字符串 |
| | | /// </summary> |
| | | [JsonProperty("echostr")] |
| | | public string Echostr { get; set; } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | public List<WxmpOptionsItem> Items { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 订阅消息 |
| | | /// </summary> |
| | | public WxmpOptionsSubscribMessage SubscribMessage { get; set; } |
| | | } |
| | | |
| | | public class WxmpOptionsSubscribMessage |
| | | { |
| | | /// <summary> |
| | | /// 令牌 |
| | | /// </summary> |
| | | public string Token { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 消息加密密钥 |
| | | /// </summary> |
| | | public string EncodingAESKey { get; set; } |
| | | } |
| | | |
| | | public class WxmpOptionsItem |
| | |
| | | if (callback == null || callback.ErrorCode != 0) |
| | | throw Oops.Oh(EnumErrorCodeType.s510, $"发送订阅消息失败:{callback.ErrorMessage},请联系管理员"); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| New file |
| | |
| | | using ApiTools.Core; |
| | | using Furion.DataEncryption; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Microsoft.Extensions.Options; |
| | | |
| | | namespace ApiTools.Web.Entry.Controllers |
| | | { |
| | | [Route("api/common/wxmp")] |
| | | public class WxmpController( |
| | | WxmpUtils utils, |
| | | IOptions<WxmpOptions> options |
| | | ) : ControllerBase |
| | | { |
| | | private readonly WxmpUtils utils = utils; |
| | | private readonly IOptions<WxmpOptions> options = options; |
| | | |
| | | [HttpGet("subscribMessageNotify")] |
| | | public IActionResult SubscribMessageNotify([FromQuery] WxmpSubscribMessageNotifyRequestQuery request) |
| | | { |
| | | var @params = new[] |
| | | { |
| | | options.Value.SubscribMessage.Token, |
| | | request.Timestamp, |
| | | request.Nonce |
| | | } |
| | | .OrderBy(p => p) |
| | | .ToArray(); |
| | | var text = string.Concat(@params); |
| | | if (SHA1Encryption.Compare(text, request.Signature, true)) |
| | | { |
| | | return Content(request.Echostr); |
| | | } |
| | | else |
| | | { |
| | | return Unauthorized("验签失败"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | "AppSecret": "9a132eda735bc925200b0e215cffe20a", |
| | | "EnvVersion": "trial" |
| | | } |
| | | ] |
| | | ], |
| | | "SubscribMessage": { |
| | | "Url": "https://sms.81812333.com/api/common/wxmp/wxmpSubscribMessageNotify", |
| | | "Token": "8Uu6CZ9KM2CAr3Q3O0YdWUYPfcXFhgMK", |
| | | "EncodingAESKey": "tbBkUB7nCgZlfton3aKMlfzHSm7QdWgnpKFibl6sjn7" |
| | | }, |
| | | }, |
| | | "Task": { |
| | | "SettlementTime": "T0" |