Example #1
0
        /// <summary>
        /// 发送语音消息(客服)
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="access_token">访问令牌</param>
        /// <returns></returns>
        public static RequestResultBaseModel SendVoiceByKF(kfVoiceMsg msg, string access_token)
        {
            if (null == msg || string.IsNullOrWhiteSpace(msg.touser))
            {
                throw new ArgumentException("参数错误", nameof(msg.touser));
            }
            if (null == msg.voice || string.IsNullOrWhiteSpace(msg.voice.media_id))
            {
                throw new ArgumentException("voice错误");
            }
            if (null == msg.customservice || string.IsNullOrWhiteSpace(msg.customservice.kf_account))
            {
                throw new ArgumentException("customservice参数不能为空");
            }

            string jsonString = JsonHelper.Serialize(msg);

            return(SendToWeCart(jsonString, access_token));
        }
Example #2
0
        public static string SendVoiceByKF(kfVoiceMsg msg)
        {
            if (null == msg || string.IsNullOrWhiteSpace(msg.touser))
            {
                return(string.Empty);
            }
            if (null == msg.voice || string.IsNullOrWhiteSpace(msg.voice.media_id))
            {
                throw new ArgumentException("voice错误");
            }
            if (null == msg.customservice || string.IsNullOrWhiteSpace(msg.customservice.kf_account))
            {
                throw new ArgumentException("customservice参数不能为空");
            }

            string jsonString = JsonHelper.Serialize(msg);

            if (!string.IsNullOrWhiteSpace(jsonString))
            {
                return(jsonString);
            }
            return(string.Empty);
        }