using Senparc.Weixin.Entities;
using Senparc.Weixin.Entities.TemplateMessage;
using Senparc.Weixin.WxOpen.AdvancedAPIs;
using Znyc.Recruitment.Admin.Commons.Core.App;
namespace Znyc.Recruitment.Admin.WeChat.CommonService.SubscribeMessage.WxApplet
{
///
/// 小程序订阅消息
///
public class WxAppletSubscribeMessage
{
private static readonly SenparcWeixinSetting senparcWeixinSetting = App.GetService();
private static readonly string weixinAppId = senparcWeixinSetting.WxOpenAppId;
///
/// 留言提醒,模板编号:1069
///
/// 接收者(用户)的 openid
/// 消息模板Id
/// 留言内容,20个以内字符
/// 留言时间,4小时制时间格式(支持+年月日) 例如:15:01,或:2019年10月1日 15:01
/// 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。
public static WxJsonResult SendCommentNotice(string toUser, string templateId, string text, string date,
string page)
{
TemplateMessageData data = new TemplateMessageData
{
["thing1"] = new(text),
["time2"] = new(date)
};
var submitData = new
{
touser = toUser,
template_id = templateId,
page,
data
};
return MessageApi.SendSubscribe(weixinAppId, toUser, templateId, data, page);
}
///
/// 新的评论提醒 ,模板编号:484
///
/// 接收者(用户)的 openid
/// 消息模板Id
/// 文章标题,20个以内字符
/// 评论内容,20个以内字符
/// 评论时间,4小时制时间格式(支持+年月日) 例如:15:01,或:2019年10月1日 15:01
/// 评论用户,20个以内字符
///
public static WxJsonResult SendRemarkNotice(string toUser, string templateId, string title, string desc,
string date, string userNick, string page)
{
TemplateMessageData data = new TemplateMessageData
{
{"thing1", new TemplateMessageDataValue(title)},
{"thing2", new TemplateMessageDataValue(desc)},
{"time3", new TemplateMessageDataValue(date)},
{"thing5", new TemplateMessageDataValue(userNick)}
};
return MessageApi.SendSubscribe(weixinAppId, toUser, templateId, data, page);
}
///
/// 动态点赞通知,模板编号:579
///
/// 接收者(用户)的 openid
/// 消息模板Id
/// 点赞用户,20个以内字符
/// 点赞时间,4小时制时间格式(支持+年月日) 例如:15:01,或:2019年10月1日 15:01
/// 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。
public static WxJsonResult SendGoodNotice(string toUser, string templateId, string name, string date,
string page)
{
TemplateMessageData data = new TemplateMessageData
{
{"name1", new TemplateMessageDataValue(name)},
{"date2", new TemplateMessageDataValue(date)}
};
return MessageApi.SendSubscribe(weixinAppId, toUser, templateId, data, page);
}
///
/// 资讯早报通知,模板编号:269
///
/// 接收者(用户)的 openid
/// 消息模板Id
/// 更新内容,20个以内字符
/// 备注,20个以内字符
/// 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。
public static WxJsonResult SendNewsMorningNotice(string toUser, string templateId, string title, string remark,
string page)
{
TemplateMessageData data = new TemplateMessageData
{
["thing1"] = new(title),
["thing2"] = new(remark)
};
var submitData = new
{
touser = toUser,
template_id = templateId,
page,
data
};
return MessageApi.SendSubscribe(weixinAppId, toUser, templateId, data, page);
}
///
/// 校验一张图片是否含有违法违规内容
/// https://developers.weixin.qq.com/miniprogram/dev/api/imgSecCheck.html
///
/// AccessToken或AppId(推荐使用AppId,需要先注册)
/// 文件完整物理路径格式支持PNG、JPEG、JPG、GIF,图片尺寸不超过 750px * 1334px
///
///
//[ApiBind(Senparc.NeuChar.PlatformType.WeChat_MiniProgram, "WxAppApi.ImgSecCheck", true)]
//public async static Task ImgSecCheck(string accessTokenOrAppId, string filePath, int timeOut = Config.TIME_OUT)
//{
// return WxOpenApiHandlerWapper.TryCommonApi(async accessToken =>
// {
// string urlFormat = Config.ApiMpHost + "/wxa/img_sec_check?access_token={0}";
// var url = urlFormat.FormatWith(accessToken);
// var fileDic = new Dictionary();
// fileDic["media"] = filePath;
// return await Senparc.CO2NET.HttpUtility.Post.PostFileGetJsonAsync(url,fileDictionary: fileDic);
// }, accessTokenOrAppId);
//}
}
}