65 lines
1.9 KiB
C#
65 lines
1.9 KiB
C#
/*
|
||
<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.Util;
|
||
using Microsoft.EntityFrameworkCore;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Threading.Tasks;
|
||
using System.Xml.Linq;
|
||
|
||
namespace Hncore.Wx.Open
|
||
{
|
||
/// <summary>
|
||
/// 扫描二维码关注
|
||
/// </summary>
|
||
public class MessageEventSubscribeQrscene : MessageMPBase
|
||
{
|
||
public MessageEventSubscribeQrscene(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_subscribe_qrscene; }
|
||
}
|
||
|
||
/// <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 = EventKey.TrimStart("qrscene_".ToCharArray());
|
||
var model = UrlHelper.ParseUrl(dataUrl);
|
||
|
||
if (model.Method == "addtag")
|
||
{
|
||
var tagid = model.Args["tagid"];
|
||
|
||
WxOpenApi.AddTag(this.AppId, new List<string>() { this.FromUserName }, tagid);
|
||
}
|
||
|
||
var userInfo = await WxOpenApi.GetUserUnionIDinfo(this.AppId, this.FromUserName);
|
||
|
||
|
||
return true;
|
||
}
|
||
}
|
||
}
|