// 素材管理接口 #region 新增临时素材 /// <summary> /// 新增临时素材 /// </summary> /// <param name="access_token"></param> /// <param name="type"></param> /// <param name="file"></param> /// <returns></returns> public static MediaUploadRes Media_Upload(string access_token, EnumUploadType type, string file) { string url = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token={0}&type={1}"; url = string.Format(url, access_token, type); TimeoutWebClient wc = ThreadWebClientFactory.GetWebClient(); wc.Encoding = Encoding.UTF8; wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); var bytes = wc.UploadFile(url, "POST", file); string json = Encoding.UTF8.GetString(bytes); MediaUploadRes res = JsonConvert.DeserializeObject <MediaUploadRes>(json); if (string.IsNullOrEmpty(res.errcode)) { res.errcode = "0"; } return(res); }