Exemple #1
0
        /// <summary>
        /// 添加临时素材
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="materialType"></param>
        /// <param name="formItems"></param>
        public AddTemporaryMaterialResultModel AddTemporaryMaterial(string accessToken, MaterialTypeEnum materialType, params FormItemModel[] formItems)
        {
            var data = new WeChatDataModel();

            data.SetValue("access_token", accessToken);
            data.SetValue("type", materialType.ToString().ToLower());
            string   url          = $"{Config.WeChatAPIUrl}cgi-bin/media/upload?{data.ToUrlParams()}";
            string   weChatResult = WeChatHttpManager.PostFormData(url, formItems, false, 3000, Config);
            JsonData jsonData     = JsonMapper.ToObject(weChatResult);

            if (WeChatPublicNumberErrorHelper.IsError(jsonData))
            {
                throw WeChatPublicNumberErrorHelper.GetWeChatException(jsonData);
            }
            var result = weChatResult.JsonToObject <AddTemporaryMaterialResultModel>();

            return(result);
        }
 public MaterialCondition(MaterialTypeEnum type, int offset, int count)
 {
     this.type   = type.ToString();
     this.offset = offset;
     this.count  = count;
 }