コード例 #1
0
        public ActionResult SendExTemplateMessage(string token, string openId,
                                                  string title, string content, string url)
        {
            if (token != _incantation)
            {
                return(Json(new { Code = 400, Message = "不被允许的访问" }));
            }
            //这里的openid为unionId 要转换为公众号的openid
            var userInfo = _userQueryService.FindByUnionId(openId);

            if (userInfo == null)
            {
                return(Json(new { Code = 400, Message = "不被允许的访问" }));
            }
            //发送模板消息
            _templateMessageService.SendExTemplateMessage(userInfo.OpenId, title, content, url);

            return(Json(new { Code = 200, Message = "发送成功" }));
        }