コード例 #1
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
            long profileId    = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            string videoAssetName       = _T("INSERT_VIDEO_ASSET_NAME_HERE");
            string pathToVideoAssetFile = _T("INSERT_PATH_TO_VIDEO_ASSET_FILE_HERE");

            Creative creative = new Creative();

            creative.AdvertiserId = advertiserId;
            creative.Name         = "Test in-stream video creative";
            creative.Type         = "INSTREAM_VIDEO";

            // Upload the video asset.
            CreativeAssetUtils assetUtils   = new CreativeAssetUtils(service, profileId, advertiserId);
            CreativeAssetId    videoAssetId = assetUtils.uploadAsset(pathToVideoAssetFile, "VIDEO");

            CreativeAsset videoAsset = new CreativeAsset();

            videoAsset.AssetIdentifier = videoAssetId;
            videoAsset.Role            = "PARENT_VIDEO";

            // Add the creative assets.
            creative.CreativeAssets = new List <CreativeAsset>()
            {
                videoAsset
            };

            Creative result = service.Creatives.Insert(creative, profileId).Execute();

            // Display the new creative ID.
            Console.WriteLine("In-stream video creative with ID {0} was created.", result.Id);
        }
コード例 #2
0
        /// <summary>
        /// Uploads a creative asset and associates it with the specified advertiser.
        /// </summary>
        /// <param name="assetFile">The path to the asset file to be uploaded</param>
        /// <param name="assetType">The CreativeAssetId type of the asset</param>
        /// <returns>
        /// A CreativeAssetMetadata object populated with the name of the asset after insert.
        /// </returns>
        public CreativeAssetMetadata uploadAsset(String assetFile, String assetType)
        {
            // Prepare an input stream.
            FileStream assetContent = new FileStream(assetFile, FileMode.Open, FileAccess.Read);

            // Create the creative asset ID and Metadata.
            CreativeAssetId assetId = new CreativeAssetId();

            assetId.Name = Path.GetFileName(assetFile);
            assetId.Type = assetType;

            CreativeAssetMetadata metaData = new CreativeAssetMetadata();

            metaData.AssetIdentifier = assetId;

            // Insert the creative.
            String mimeType = determineMimeType(assetFile, assetType);

            CreativeAssetsResource.InsertMediaUpload request =
                Service.CreativeAssets.Insert(metaData, ProfileId, AdvertiserId, assetContent, mimeType);

            IUploadProgress progress = request.Upload();

            if (UploadStatus.Failed.Equals(progress.Status))
            {
                throw progress.Exception;
            }

            // Display the new asset name.
            Console.WriteLine("Creative asset was saved with name \"{0}\".",
                              request.ResponseBody.AssetIdentifier.Name);
            return(request.ResponseBody);
        }
コード例 #3
0
        /// <summary>
        /// Uploads a creative asset and associates it with the specified advertiser.
        /// </summary>
        /// <param name="assetFile">The path to the asset file to be uploaded</param>
        /// <param name="assetType">The CreativeAssetId type of the asset</param>
        /// <returns>
        /// A CreativeAssetId object populated with the name of the asset after insert.
        /// </returns>
        public CreativeAssetId uploadAsset(String assetFile, String assetType)
        {
            // Prepare an input stream.
              FileStream assetContent = new FileStream(assetFile, FileMode.Open, FileAccess.Read);

              // Create the creative asset ID and Metadata.
              CreativeAssetId assetId = new CreativeAssetId();
              assetId.Name = Path.GetFileName(assetFile);
              assetId.Type = assetType;

              CreativeAssetMetadata metaData = new CreativeAssetMetadata();
              metaData.AssetIdentifier = assetId;

              // Insert the creative.
              String mimeType = determineMimeType(assetFile, assetType);
              CreativeAssetsResource.InsertMediaUpload request =
              Service.CreativeAssets.Insert(metaData, ProfileId, AdvertiserId, assetContent, mimeType);
              request.Upload();

              // Display the new asset name.
              Console.WriteLine("Creative asset was saved with name \"{0}\".",
            request.ResponseBody.AssetIdentifier.Name);

              return request.ResponseBody.AssetIdentifier;
        }
コード例 #4
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
            long sizeId       = long.Parse(_T("INSERT_SIZE_ID_HERE"));
            long profileId    = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            string pathToHtml5AssetFile = _T("INSERT_PATH_TO_HTML5_ASSET_FILE_HERE");
            string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

            Creative creative = new Creative();

            creative.AdvertiserId = advertiserId;
            creative.Name         = "Test HTML5 banner creative";
            creative.Size         = new Size()
            {
                Id = sizeId
            };
            creative.Type = "HTML5_BANNER";

            // Upload the HTML5 asset.
            CreativeAssetUtils assetUtils   = new CreativeAssetUtils(service, profileId, advertiserId);
            CreativeAssetId    html5AssetId = assetUtils.uploadAsset(pathToHtml5AssetFile, "HTML");

            CreativeAsset html5Asset = new CreativeAsset();

            html5Asset.AssetIdentifier = html5AssetId;
            html5Asset.Role            = "PRIMARY";

            // Upload the backup image asset.
            CreativeAssetId imageAssetId = assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE");

            CreativeAsset imageAsset = new CreativeAsset();

            imageAsset.AssetIdentifier = imageAssetId;
            imageAsset.Role            = "BACKUP_IMAGE";

            // Add the creative assets.
            creative.CreativeAssets = new List <CreativeAsset>()
            {
                html5Asset, imageAsset
            };

            // Add a click tag.
            ClickTag clickTag = new ClickTag()
            {
                Name = "clickTag"
            };

            creative.ClickTags = new List <ClickTag>()
            {
                clickTag
            };

            Creative result = service.Creatives.Insert(creative, profileId).Execute();

            // Display the new creative ID.
            Console.WriteLine("HTML5 banner creative with ID {0} was created.", result.Id);
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
            long sizeId       = long.Parse(_T("INSERT_SIZE_ID_HERE"));
            long profileId    = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            string pathToFlashAssetFile = _T("INSERT_PATH_TO_FLASH_ASSET_FILE_HERE");
            string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

            Creative creative = new Creative();

            creative.AdvertiserId = advertiserId;
            creative.Name         = "Test flash display creative";
            creative.Size         = new Size()
            {
                Id = sizeId
            };
            creative.Type = "ENHANCED_BANNER";

            // Upload the flash asset.
            CreativeAssetUtils assetUtils   = new CreativeAssetUtils(service, profileId, advertiserId);
            CreativeAssetId    flashAssetId = assetUtils.uploadAsset(pathToFlashAssetFile, "FLASH");

            CreativeAsset flashAsset = new CreativeAsset();

            flashAsset.AssetIdentifier = flashAssetId;
            flashAsset.Role            = "PRIMARY";
            flashAsset.WindowMode      = "TRANSPARENT";

            // Upload the backup image asset.
            CreativeAssetId imageAssetId = assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE");

            CreativeAsset imageAsset = new CreativeAsset();

            imageAsset.AssetIdentifier = imageAssetId;
            imageAsset.Role            = "BACKUP_IMAGE";

            // Add the creative assets.
            creative.CreativeAssets = new List <CreativeAsset>()
            {
                flashAsset, imageAsset
            };

            // Configure the backup image.
            creative.BackupImageClickThroughUrl = "https://www.google.com";
            creative.BackupImageReportingLabel  = "backup";
            creative.BackupImageTargetWindow    = new TargetWindow()
            {
                TargetWindowOption = "NEW_WINDOW"
            };

            Creative result = service.Creatives.Insert(creative, profileId).Execute();

            // Display the new creative ID.
            Console.WriteLine("Flash display creative with ID {0} was created.", result.Id);
        }
コード例 #6
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
            long sizeId       = long.Parse(_T("INSERT_SIZE_ID_HERE"));
            long profileId    = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

            Creative creative = new Creative();

            creative.AdvertiserId = advertiserId;
            creative.Name         = "Test image display creative";
            creative.Size         = new Size()
            {
                Id = sizeId
            };
            creative.Type = "DISPLAY";

            // Upload the image asset.
            CreativeAssetUtils assetUtils   = new CreativeAssetUtils(service, profileId, advertiserId);
            CreativeAssetId    imageAssetId =
                assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE").AssetIdentifier;

            CreativeAsset imageAsset = new CreativeAsset();

            imageAsset.AssetIdentifier = imageAssetId;
            imageAsset.Role            = "PRIMARY";

            // Add the creative assets.
            creative.CreativeAssets = new List <CreativeAsset>()
            {
                imageAsset
            };

            Creative result = service.Creatives.Insert(creative, profileId).Execute();

            // Display the new creative ID.
            Console.WriteLine("Image display creative with ID {0} was created.", result.Id);
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
            long sizeId       = long.Parse(_T("INSERT_SIZE_ID_HERE"));
            long profileId    = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            string pathToImageAssetFile  = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");
            string pathToImageAsset2File = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

            Creative creative = new Creative();

            creative.AdvertiserId      = advertiserId;
            creative.AutoAdvanceImages = true;
            creative.Name = "Test display image gallery creative";
            creative.Size = new Size()
            {
                Id = sizeId
            };
            creative.Type = "DISPLAY_IMAGE_GALLERY";

            // Upload the first image asset.
            CreativeAssetUtils assetUtils    = new CreativeAssetUtils(service, profileId, advertiserId);
            CreativeAssetId    imageAsset1Id =
                assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE").AssetIdentifier;

            CreativeAsset imageAsset1 = new CreativeAsset();

            imageAsset1.AssetIdentifier = imageAsset1Id;
            imageAsset1.Role            = "PRIMARY";

            // Upload the second image asset.
            CreativeAssetId imageAsset2Id =
                assetUtils.uploadAsset(pathToImageAsset2File, "HTML_IMAGE").AssetIdentifier;

            CreativeAsset imageAsset2 = new CreativeAsset();

            imageAsset2.AssetIdentifier = imageAsset2Id;
            imageAsset2.Role            = "PRIMARY";

            // Add the creative assets.
            creative.CreativeAssets = new List <CreativeAsset>()
            {
                imageAsset1, imageAsset2
            };

            // Create a click tag for the first image asset.
            ClickTag clickTag1 = new ClickTag();

            clickTag1.Name      = imageAsset1Id.Name;
            clickTag1.EventName = imageAsset1Id.Name;

            // Create a click tag for the second image asset.
            ClickTag clickTag2 = new ClickTag();

            clickTag2.Name      = imageAsset2Id.Name;
            clickTag2.EventName = imageAsset2Id.Name;

            // Add the click tags.
            creative.ClickTags = new List <ClickTag>()
            {
                clickTag1, clickTag2
            };

            Creative result = service.Creatives.Insert(creative, profileId).Execute();

            // Display the new creative ID.
            Console.WriteLine("Display image gallery creative with ID {0} was created.", result.Id);
        }
コード例 #8
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
            long sizeId       = long.Parse(_T("INSERT_SIZE_ID_HERE"));
            long profileId    = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            string pathToHtml5AssetFile = _T("INSERT_PATH_TO_HTML5_ASSET_FILE_HERE");
            string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

            Creative creative = new Creative();

            creative.AdvertiserId = advertiserId;
            creative.Name         = "Test HTML5 display creative";
            creative.Size         = new Size()
            {
                Id = sizeId
            };
            creative.Type = "DISPLAY";

            // Upload the HTML5 asset.
            CreativeAssetUtils assetUtils   = new CreativeAssetUtils(service, profileId, advertiserId);
            CreativeAssetId    html5AssetId =
                assetUtils.uploadAsset(pathToHtml5AssetFile, "HTML").AssetIdentifier;

            CreativeAsset html5Asset = new CreativeAsset();

            html5Asset.AssetIdentifier = html5AssetId;
            html5Asset.Role            = "PRIMARY";

            // Upload the backup image asset.
            CreativeAssetId imageAssetId =
                assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE").AssetIdentifier;

            CreativeAsset imageAsset = new CreativeAsset();

            imageAsset.AssetIdentifier = imageAssetId;
            imageAsset.Role            = "BACKUP_IMAGE";

            // Add the creative assets.
            creative.CreativeAssets = new List <CreativeAsset>()
            {
                html5Asset, imageAsset
            };

            // Configure the bacup image.
            creative.BackupImageClickThroughUrl = "https://www.google.com";
            creative.BackupImageReportingLabel  = "backup";
            creative.BackupImageTargetWindow    = new TargetWindow()
            {
                TargetWindowOption = "NEW_WINDOW"
            };

            // Add a click tag.
            ClickTag clickTag = new ClickTag();

            clickTag.Name      = "clickTag";
            clickTag.EventName = "exit";
            clickTag.Value     = "https://www.google.com";
            creative.ClickTags = new List <ClickTag>()
            {
                clickTag
            };

            Creative result = service.Creatives.Insert(creative, profileId).Execute();

            // Display the new creative ID.
            Console.WriteLine("HTML5 display creative with ID {0} was created.", result.Id);
        }