Example #1
0
        public void GetUserList()
        {
            dynamic userinfo = AdminAPI.GetUserList(WeixinConfig.AccessTokenHelper.GetToken());

            foreach (var _id in userinfo.data.openid)
            {
                ReplayActiveMessageAPI.RepayText(WeixinConfig.AccessTokenHelper.GetToken(), _id, "Hello");
            }
        }
Example #2
0
        //发送客服消息
        public ActionResult SendMessage(int id)
        {
            var reply = _message.GetById(id);

            if (reply == null || string.IsNullOrEmpty(reply.Openid))
            {
                return(Json("数据异常或者openid为空"));
            }
            var config = _config.GetConfig(reply.WeiXinId);
            var openId = reply.Openid;
            var result = false;

            switch (Convert.ToInt32(reply.MsgType))
            {
            case (int)WeiXinMessageTypeEnum.text:
                result = ReplayActiveMessageAPI.RepayText(config.AccessToken, openId, reply.Content);
                break;

            case (int)WeiXinMessageTypeEnum.image:
                result = ReplayActiveMessageAPI.RepayImage(config.AccessToken, openId, reply.MediaId);
                break;

            case (int)WeiXinMessageTypeEnum.video:
                result = ReplayActiveMessageAPI.RepayVedio(config.AccessToken, openId, reply.MediaId, reply.ThumbMediaId, reply.Title, reply.Description);
                break;

            case (int)WeiXinMessageTypeEnum.voice:
                result = ReplayActiveMessageAPI.RepayVoice(config.AccessToken, openId, reply.MediaId);
                break;

            case (int)WeiXinMessageTypeEnum.music:
                result = ReplayActiveMessageAPI.RepayMusic(config.AccessToken, openId, reply.Title, reply.Description, reply.MusicURL, reply.HQMusicUrl, reply.ThumbMediaId);
                break;

            case (int)WeiXinMessageTypeEnum.news:
                var weiXinNewList = new List <WeixinNews>();
                var titles        = reply.Title.Split(';');
                var descriptions  = reply.Description.Split(';');
                var picurls       = reply.PicUrl.Split(';');
                var urls          = reply.Url.Split(';');
                for (int i = 0; i < reply.ArticleCount; i++)
                {
                    var weiXinNew = new WeixinNews
                    {
                        title       = titles[i],
                        description = descriptions[i],
                        picurl      = picurls[i],
                        url         = urls[i]
                    };
                    weiXinNewList.Add(weiXinNew);
                }

                result = ReplayActiveMessageAPI.RepayNews(config.AccessToken, openId, weiXinNewList);
                break;
            }
            return(Json(result));
        }