ConfigHelper configHelper = new ConfigHelper();
string appid = configHelper.GetValueByKey("AppID");
string secret = configHelper.GetValueByKey("AppSecret");
string SendMsg_TemplateId = configHelper.GetValueByKey("SendMsg_TemplateId");
string accessToken = WxBase.GetAccessToken(appid, secret);
var postData = new
{
touser = openid,
template_id = SendMsg_TemplateId,
data = new
{
first = new
{
value=title,
color = "#0d7d1e"
},
keyword1 = new
{
value = name,
color = "#173177"
},
keyword2 = new
{
value = tel,
color = "#173177"
},
keyword3 = new
{
value = goodname,
color = "#173177"
},
keyword4 = new
{
value = goodcount,
color = "#173177"
},
keyword5 = new
{
value = time,
color = "#173177"
},
remark = new
{
value = msg,
color = "#173177"
}
}
};
return HttpHelper.HttpPost("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken, JsonConvert.SerializeObject
(postData));
模板ID是再公众号中查找的,或者自己进行申请的
然后根据别人的格式,进行发送信息,即可