コード例 #1
0
        /// <summary>
        /// 新增临时素材
        /// </summary>
        /// <param name="file">文件流</param>
        /// <param name="fileName">文件名称</param>
        /// <param name="type">媒体文件类型,分别有图片(image)、语音(voice)、视频(video)和缩略图(thumb)</param>
        /// <returns></returns>
        public static EntMediaResult AddMedia(Stream file, string fileName, EntMediaType type)
        {
            MultipartFormDataContent content = EntInterface.BuildFromContent(fileName, file);

            var url = string.Format(ADD_MEDIA_URL, EntInterface.AccessToken, type.ToString());

            return(WebApiHelper.PostHttpContent <EntMediaResult>(url, content));
        }
コード例 #2
0
        /// <summary>
        /// 读取永久素材列表
        /// </summary>
        /// <param name="type">类型 不能为news</param>
        /// <param name="offset">从全部素材的该偏移位置开始返回,0表示从第一个素材 默认0</param>
        /// <param name="count">返回素材的数量,取值在1到20之间,默认20</param>
        /// <returns></returns>
        public static EntMeterialResult GetMaterialList(EntMediaType type, int offset, int count = 20)
        {
            var url = string.Format(GET_MATERIAL_LIST_URL, EntInterface.AccessToken);

            if (type == EntMediaType.news)
            {
                throw new Exception("news请使用GetMaterialNewsList");
            }

            return(WebApiHelper.PostAsync <EntMeterialResult>(url, new { type = type.ToString(), offset = offset, count = count }));
        }