Ejemplo n.º 1
0
        public Result <Template> AddTpl(Dictionary <string, string> param, string layout, byte[] material)
        {
            var r = new Result <Template>();

            r = CheckParam(ref param, r, Const.Apikey, Const.Sign);
            if (!r.IsSucc())
            {
                return(r);
            }


            var data = new MultipartFormDataContent();

            foreach (var kv in param)
            {
                data.Add(new StringContent(kv.Value, Encoding.GetEncoding(Charset),
                                           "text/plain"), kv.Key);
            }

            data.Add(new StringContent(layout, Encoding.GetEncoding(Charset),
                                       "application/x-www-form-urlencoded"), Const.Layout);

            var httpContent = new ByteArrayContent(material);

            httpContent.Headers.Add("Content-Type", $"application/octet-stream;charset={Charset}");
            data.Add(httpContent, Const.Material);


            var h = new StdResultHandler <Template>();

            try
            {
                Path = "add_tpl.json";
                return(Post(data, h, r));
            }
            catch (Exception e)
            {
                return(h.CatchExceptoin(e, r));
            }
        }
Ejemplo n.º 2
0
        /**
         * 获取视频短信模版状态
         *
         * @param param
         *            apikey tpl_id
         * @return
         */
        public Result <Template> GetTpl(Dictionary <string, string> param)
        {
            var r = new Result <Template>();

            r = CheckParam(ref param, r, Const.Apikey, Const.TplId);

            if (!r.IsSucc())
            {
                return(r);
            }
            var data = UrlEncode(ref param);

            var h = new StdResultHandler <Template>();

            try
            {
                Path = "get_tpl.json";
                return(Post(ref data, h, r));
            }
            catch (Exception e)
            {
                return(h.CatchExceptoin(e, r));
            }
        }