Sugar.WeChat
引用工具类
Install-Package Sugar.WeChat -Version 1.1.2
在也可在项目 nuget中添加Sugar.WeChat
startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.UseWeChatTemplateMessage(o => { o.AppId = "你的appid";o.AppSecret = "你的appsecret"; });
}
控制器
public class WeChatTemplageMessageController : Controller
{
Sugar.WeChat.TemplateMsg.TemplateMessageProvider provider;
public WeChatTemplageMessageController(Sugar.WeChat.TemplateMsg.TemplateMessageProvider provider)
{
this.provider = provider;
}
public async Task<IActionResult> IndexAsync()
{
await provider.SendOffiAccountMessageAsync(new OffiAccountMessage()
{
TemplateId = "JLc7M--uP751GxvVf2_Msqp1m_gne0XXiSzJISloy8g",
Url = "www.baidu.com",
Data = new MessageContent()
{
MessageTitle = new MessageContentItem("测试title"),
MessageDatas = new List<MessageContentItem>() { new MessageContentItem("数据1"), new MessageContentItem("数据2") },
Remark = new MessageContentItem("备注信息")
}
}, "o6qCa1CdDnDQhEkPmwWJynGMQ4Ho");
return View();
}
}
demo源码 https://github.com/iml6yu/Sugar.WeChat
|
请发表评论