Ejemplo n.º 1
0
 /// <summary>
 /// 传入:ToUser,TemplateId,Url,Data(Dictionary&lt;string,string>)。可传:WeChatPublic
 /// </summary>
 public WeChatResult SendTemplate(MsgParam msg)
 {
     var sss = new Dictionary<string,object>();
     foreach (var dic in msg.Data)
     {
         sss.Add(dic.Key,new
         {
             value = dic.Value,
             color= "#173177"
         });
     }
     var param = JsonConvert.SerializeObject(new
     {
         touser = msg.ToUser,
         template_id = msg.TemplateId,
         url = msg.Url,
         topcolor = "#FF0000",
         data = sss
     });
     var result = HttpHelper.Post<WeChatResult>(ApiList.MessageTemplateSendUrl, param, "access_token=" + Token.GetAccessToken(msg));
     return result;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 
 /// </summary>
 public WeChatResult Send(MsgParam msg)
 {
     var result = HttpHelper.Post<WeChatResult>(ApiList.MessageCustomSendUrl, msg.ToString(),
         "access_token=" + Token.GetAccessToken(msg));
     return result;
 }