Files
juipnet/Infrastructure/WxApi/Notice/MpMessage/MessageEventScan.cs
“wanyongkang” ed3b2c653e 接口文件
2024-04-10 13:55:27 +08:00

61 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[FromUser]]></FromUserName>
<CreateTime>123456789</CreateTime>
<MsgType><![CDATA[event]]></MsgType>
<Event><![CDATA[subscribe]]></Event>
<EventKey><![CDATA[qrscene_123123]]></EventKey>
<Ticket><![CDATA[TICKET]]></Ticket>
</xml>
*/
using Hncore.Pass.MsgCenter.Constant;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Xml.Linq;
using Hncore.Pass.MsgCenter.Util;
namespace Hncore.Wx.Open
{
/// <summary>
/// 扫描二维码关注
/// </summary>
public class MessageEventScan : MessageMPBase
{
public MessageEventScan(XDocument doc) : base(doc)
{
this.EventKey = doc.Root.Element("EventKey").Value;
this.Ticket = doc.Root.Element("Ticket").Value;
}
public override RequestInfoType InfoType
{
get { return RequestInfoType.event_SCAN; }
}
/// <summary>
/// 事件KEY值qrscene_为前缀后面为二维码的参数值
/// </summary>
public string EventKey { get; set; }
/// <summary>
/// 二维码的ticket可用来换取二维码图片
/// </summary>
public string Ticket { get; set; }
public override async Task<bool> Handler()
{
///参数形式 method?a=1&b=2
var dataUrl = this.EventKey;
var model = UrlHelper.ParseUrl(dataUrl);
if (model.Method == "addtag")
{
var tagid = model.Args["tagid"];
WxOpenApi.AddTag(this.AppId, new List<string>() { this.FromUserName }, tagid);
}
return true;
}
}
}