Ejemplo n.º 1
0
        public static string GetCreativeList()
        {
            string    type     = "news";
            int       offset   = 0;
            int       count    = 1;
            IMpClient mpClient = new MpClient();
            var       request  = new AccessTokenGetRequest()
            {
                AppIdInfo = new AppIdInfo()
                {
                    AppId = AppId, AppSecret = AppSecret
                }
            };
            var response = mpClient.Execute(request);

            if (response.IsError)
            {
                return(null);
            }

            MaterialList materialList = new MaterialList
            {
                Type   = type,
                Offset = offset,
                Count  = count
            };

            var requestUpload = new GetMaterialListRequest
            {
                AccessToken = response.AccessToken.AccessToken,
                SendData    = materialList.ToJsonString()
            };
            var createResponse = mpClient.Execute(requestUpload);

            if (createResponse.IsError)
            {
                LogHelper.WriteLog(typeof(StatisticsOperation), createResponse.ErrInfo.ErrMsg);
                return(createResponse.ErrInfo.ErrMsg);
            }
            var jsonSerializer = new JavaScriptSerializer();

            return(jsonSerializer.Serialize(createResponse.Body));
        }