Exemplo n.º 1
0
        public async Task <ServiceResult <WxEE_AppMsgTextMsgOutput> > push_text(WxEE_AppMsgTextMsgInput input)
        {
            var result = await _ee_push.PushTextMessage(input);

            Response.StatusCode = result.code;
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 发送应用文本消息
        /// </summary>
        /// <returns></returns>
        public async Task <ServiceResult <WxEE_AppMsgTextMsgOutput> > PushTextMessage(WxEE_AppMsgTextMsgInput input)
        {
            input.CheckNull(nameof(WxEE_AppMsgTextMsgInput));
            input.guid.CheckEmpty(nameof(input.guid));
            input.userid.CheckEmpty(nameof(input.userid));
            input.content.CheckEmpty(nameof(input.content));

            //读取配置
            var wechatEEApp = _middleDB.WechatEeappConfig.FirstOrDefault(w => w.Guid == input.guid);

            if (wechatEEApp == null)
            {
                return(ServiceResult <WxEE_AppMsgTextMsgOutput> .Failed(StatusCodes.Status404NotFound, "微信配置获取失败,请联系系统客服"));
            }
            var token = _tokenService.GetAccessToken(new WxEE_AuthorizeAccessTokenInput {
                guid = input.guid
            });
            var text = new WxEE_PushAppTextMessage();

            text.agentid      = wechatEEApp.AgentId;
            text.touser       = input.userid;
            text.text.content = input.content;
            //发送
            var result = await WxEEContext.PushAppMessageAPI.SendAppMessage(token.data.access_token, text);

            return(ServiceResult <WxEE_AppMsgTextMsgOutput> .Success(new WxEE_AppMsgTextMsgOutput { invaliduser = result.invaliduser }));
        }