Пример #1
0
        /// <summary>
        /// 获取模板list
        /// </summary>
        /// <returns>模板列表json数据</returns>
        public string GetTemplateList()
        {
            string        url      = Until.CreateUrl(UrlConfig.GetTemplateList);
            RequestHelper request  = new RequestHelper();
            string        response = request.GetResponseString(request.CreateGetHttpResponse(url));

            return(response);
        }
Пример #2
0
        /// <summary>
        /// 设置行业
        /// </summary>
        /// <param name="id1">主行业</param>
        /// <param name="id2">副行业</param>
        public void SetIndustry(string id1, string id2)
        {
            string url = Until.CreateUrl(UrlConfig.SetIndustry);
            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic["industry_id1"] = id1;
            dic["industry_id1"] = id2;
            RequestHelper request  = new RequestHelper();
            string        response = request.GetResponseString(request.CreatePostHttpResponse(url, dic));
        }
Пример #3
0
        /// <summary>
        /// 获取微信服务器IP地址
        /// </summary>
        /// <returns>返回数据</returns>
        public string GetIP()
        {
            string        url      = Until.CreateUrl(UrlConfig.IPURL);
            RequestHelper request  = new RequestHelper();
            string        response = request.GetResponseString(request.CreateGetHttpResponse(url));
            JObject       obj      = JObject.Parse(response);

            if (response.Contains("errcode"))
            {
                throw new Exception(errMsg.GetErrMsg((int)obj["errcode"]));
            }

            return(response);
        }
Пример #4
0
        /// <summary>
        /// 获取模板ID
        /// </summary>
        /// <param name="id">shortID</param>
        /// <returns>返回信息</returns>
        public string GetTemplateID(string id)
        {
            string url = Until.CreateUrl(UrlConfig.GetTemplateID);
            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic["template_id_short"] = id;
            RequestHelper request  = new RequestHelper();
            string        response = request.GetResponseString(request.CreatePostHttpResponse(url, dic));
            JObject       obj      = JObject.Parse(response);

            if ((int)obj["errcode"] != 0)
            {
                throw new Exception(errMsg.GetErrMsg((int)obj["errcode"]));
            }
            else
            {
                return(response);
            }
        }
Пример #5
0
        public void GetUserChildrenList(string openid, JArray UserList)
        {
            string        url      = Until.CreateUrl(UrlConfig.GetUserList) + "&next_openid=" + openid;
            RequestHelper request  = new RequestHelper();
            string        response = request.GetResponseString(request.CreateGetHttpResponse(url));
            JObject       obj      = JObject.Parse(response);

            if (response.Contains("errcode"))
            {
                throw new Exception(errMsg.GetErrMsg((int)obj["errcode"]));
            }
            if (obj["next_openid"] != null && obj["next_openid"].ToString() != "")
            {
                JArray UserChildrenList = JArray.Parse(obj["openid"].ToString());
                foreach (var item in UserChildrenList)
                {
                    UserList.Add(item);
                }
                GetUserChildrenList(obj["next_openid"].ToString(), UserList);
            }
        }
Пример #6
0
        /// <summary>
        /// 获取关注本公众号内前10000个人的openid,超过10000万人递归拼接成一条完整的消息
        /// </summary>
        /// <param name="openid">从哪个人开始查询,可不填</param>
        /// <param name="GetAll">是否获取全部关注的用户信息,默认false,填入true则递归拉取全部数据</param>
        /// <returns></returns>
        public string GetUserList(string openid = null, bool GetAll = false)
        {
            string        url      = Until.CreateUrl(UrlConfig.GetUserList) + "&next_openid=" + openid;
            RequestHelper request  = new RequestHelper();
            string        response = request.GetResponseString(request.CreateGetHttpResponse(url));
            JObject       obj      = JObject.Parse(response);

            if (response.Contains("errcode"))
            {
                throw new Exception(errMsg.GetErrMsg((int)obj["errcode"]));
            }
            if (obj["next_openid"] != null && obj["next_openid"].ToString() != "" && GetAll)
            {
                JArray UserList = JArray.Parse(obj["openid"].ToString());
                GetUserChildrenList(obj["next_openid"].ToString(), UserList);
                return(obj.ToString());
            }
            else
            {
                return(obj.ToString());
            }
        }
Пример #7
0
        /// <summary>
        /// 推送模板消息
        /// </summary>
        /// <param name="openid">推送目标人openid</param>
        /// <param name="templateid">推送的模板id</param>
        /// <param name="data">推送的data数据,必须为json格式</param>
        /// <param name="appid">点击跳转的appid,绑定在平台上</param>
        /// <param name="appurl">模板跳转url</param>
        /// <param name="miniprogram">跳小程序所需数据</param>
        /// <param name="pagepath">所需跳转到小程序的具体页面路径</param>
        /// <param name="color">模板内容字体颜色,不填默认为黑色</param>
        /// <returns></returns>
        public string SendTemplateMsg(string openid, string templateid, object data, string appid = null, string appurl = null, string pagepath = null, string color = null)
        {
            string url = Until.CreateUrl(UrlConfig.SendTemplateMsg);
            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic["touser"]      = openid?.Trim();
            dic["template_id"] = templateid?.Trim();
            dic["topcolor"]    = "#D5D5D5";
            if (appurl != null)
            {
                dic["url"] = appurl;
            }
            if (!string.IsNullOrEmpty(appid))
            {
                dic["miniprogram"] = new { appid, pagepath };
            }
            //dic["appid"] = appid;
            if (pagepath != null)
            {
                dic["pagepath"] = pagepath;
            }
            dic["data"] = data;
            if (color != null)
            {
                dic["color"] = color;
            }
            RequestHelper request  = new RequestHelper();
            string        response = request.GetResponseString(request.CreatePostHttpResponse(url, dic));
            JObject       obj      = JObject.Parse(response);

            if ((int)obj["errcode"] != 0)
            {
                throw new Exception(response);
            }
            else
            {
                return(response);
            }
        }