/// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The Dfa user object running the code example.
        /// </param>
        public override void Run(DfaUser user)
        {
            // Request the creative service from the service client factory.
            CreativeRemoteService creativeService = (CreativeRemoteService)user.GetService(
                DfaService.v1_19.CreativeRemoteService);

            long creativeId = long.Parse(_T("INSERT_IN_STREAM_VIDEO_CREATIVE_ID_HERE"));

            try {
                // Fetch the In-Stream video creative which contains the asset to modify.
                CreativeBase rawCreative = creativeService.getCreative(creativeId);

                if (!(rawCreative is InStreamVideoCreative))
                {
                    Console.WriteLine("Unable to update creative with ID \"{0}\": not an In-Stream video "
                                      + "creative.", creativeId);
                }
                else
                {
                    InStreamVideoCreative inStreamVideoCreative = (InStreamVideoCreative)rawCreative;

                    // Modify the media files, companion ads, and/or non-linear ads.
                    if (inStreamVideoCreative.mediaFiles != null)
                    {
                        foreach (InStreamMediaFile mediaFile in inStreamVideoCreative.mediaFiles)
                        {
                            mediaFile.pickedToServe = !mediaFile.pickedToServe;
                        }
                    }

                    if (inStreamVideoCreative.companionAds != null)
                    {
                        foreach (InStreamCompanionAd companionAd in inStreamVideoCreative.companionAds)
                        {
                            companionAd.altText = companionAd.altText + " Updated.";
                        }
                    }

                    if (inStreamVideoCreative.nonLinearAds != null)
                    {
                        foreach (InStreamNonLinearAd nonLinearAd in inStreamVideoCreative.nonLinearAds)
                        {
                            nonLinearAd.scalable = !nonLinearAd.scalable;
                        }
                    }

                    CreativeSaveResult creativeSaveResult =
                        creativeService.saveCreative(inStreamVideoCreative, 0);

                    Console.WriteLine("Updated the In-Stream assets of In-Stream video creative with ID "
                                      + "\"{0}\".", creativeSaveResult.id);
                }
            } catch (Exception ex) {
                Console.WriteLine("Failed to update in-stream assets of in-stream video creative. " +
                                  "Exception says \"{0}\"", ex.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The Dfa user object running the code example.
        /// </param>
        public override void Run(DfaUser user)
        {
            // Create CreativeRemoteService instance.
            CreativeRemoteService service = (CreativeRemoteService)user.GetService(
                DfaService.v1_19.CreativeRemoteService);

            long   advertiserId     = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
            String creativeName     = _T("INSERT_CREATIVE_NAME_HERE");
            String swfAssetFileName = _T("INSERT_SWF_ASSET_FILE_NAME_HERE");
            String imgAssetFileName = _T("INSERT_IMG_ASSET_FILE_NAME_HERE");
            long   sizeId           = long.Parse(_T("INSERT_SIZE_ID_HERE"));
            long   typeId           = long.Parse(_T("INSERT_TYPE_ID_HERE"));

            // Create flash inpage structure.
            FlashInpageCreative flashInpage = new FlashInpageCreative();

            flashInpage.typeId       = typeId;
            flashInpage.id           = 0;
            flashInpage.name         = creativeName;
            flashInpage.advertiserId = advertiserId;
            flashInpage.active       = true;
            flashInpage.codeLocked   = true;
            flashInpage.sizeId       = sizeId;

            // Set parent flash asset structure.
            HTMLCreativeFlashAsset parentFlashAsset = new HTMLCreativeFlashAsset();

            parentFlashAsset.assetFilename = swfAssetFileName;
            flashInpage.parentFlashAsset   = parentFlashAsset;
            flashInpage.wmode = "opaque";

            // Set backup image asset.
            HTMLCreativeAsset backupImageAsset = new HTMLCreativeAsset();

            backupImageAsset.assetFilename = imgAssetFileName;
            flashInpage.backupImageAsset   = backupImageAsset;

            // Set target window for backup image.
            TargetWindow backupImageTargetWindow = new TargetWindow();

            backupImageTargetWindow.option      = "_blank";
            flashInpage.backupImageTargetWindow = backupImageTargetWindow;

            try {
                // Create flash inpage creative.
                CreativeSaveResult result = service.saveCreative(flashInpage, 0);

                // Display new creative id.
                Console.WriteLine("Flash inpage creative with id \"{0}\" was created.", result.id);
            } catch (Exception e) {
                Console.WriteLine("Failed to create advertiser. Exception says \"{0}\"",
                                  e.Message);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The Dfa user object running the code example.
        /// </param>
        public override void Run(DfaUser user)
        {
            // Request the creative service from the service client factory.
            CreativeRemoteService creativeService = (CreativeRemoteService)user.GetService(
                DfaService.v1_20.CreativeRemoteService);

            long   advertiserId    = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
            long   campaignId      = 0;
            float  videoDuration   = float.Parse(_T("INSERT_VIDEO_DURATION_HERE"));
            string adId            = _T("INSERT_VAST_AD_ID_HERE");
            string surveyUrl       = _T("INSERT_VAST_SURVEY_URL_HERE");
            string clickThroughUrl = _T("INSERT_VAST_CLICK_THROUGH_URL_HERE");

            // Create the In-Stream video creative.
            InStreamVideoCreative inStreamVideoCreative = new InStreamVideoCreative();

            inStreamVideoCreative.advertiserId  = advertiserId;
            inStreamVideoCreative.name          = "In-Stream Video Creative #" + GetTimeStamp();
            inStreamVideoCreative.videoDuration = videoDuration;
            // In-Stream video creatives have to be created inactive. One can only be
            // set active after at least one media file has been added to it or the API
            // will return an error message.
            inStreamVideoCreative.active = false;

            // Set the video details based on the Video Ad Serving Template (VAST)
            // specification.
            inStreamVideoCreative.adId            = adId;
            inStreamVideoCreative.description     = "You are viewing an In-Stream Video Creative";
            inStreamVideoCreative.surveyUrl       = surveyUrl;
            inStreamVideoCreative.clickThroughUrl = clickThroughUrl;

            try {
                // Save the In-Stream video creative.
                CreativeSaveResult creativeSaveResult = creativeService.saveCreative(inStreamVideoCreative,
                                                                                     campaignId);

                // Display the new creative ID.
                Console.WriteLine("In-Stream video creative with ID \"{0}\" was created.",
                                  creativeSaveResult.id);
            } catch (Exception ex) {
                Console.WriteLine("Failed to create in-stream video creative. Exception says \"{0}\"",
                                  ex.Message);
            }
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The Dfa user object running the code example.
        /// </param>
        public override void Run(DfaUser user)
        {
            // Create CreativeRemoteService instance.
            CreativeRemoteService service = (CreativeRemoteService)user.GetService(
                DfaService.v1_19.CreativeRemoteService);

            long   advertiserId        = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
            String creativeName        = _T("INSERT_CREATIVE_NAME_HERE");
            String mobileAssetFileName = _T("INSERT_MOBILE_ASSET_FILE_NAME_HERE");
            long   typeId = long.Parse(_T("INSERT_TYPE_ID_HERE"));

            // Set mobile display creative structure.
            MobileDisplayCreative mobileDisplayCreative = new MobileDisplayCreative();

            mobileDisplayCreative.advertiserId = advertiserId;
            mobileDisplayCreative.name         = creativeName;
            mobileDisplayCreative.typeId       = typeId;
            mobileDisplayCreative.archived     = false;

            // Set mobile creative asset.
            HTMLCreativeAsset htmlCreativeAsset = new MobileDisplayCreativeAsset();

            htmlCreativeAsset.assetFilename      = mobileAssetFileName;
            mobileDisplayCreative.creativeAssets = new HTMLCreativeAsset[] { htmlCreativeAsset };

            try {
                // Create mobile display creative.
                CreativeSaveResult creativeSaveResult = service.saveCreative(mobileDisplayCreative, 0);

                // Display new creative id.
                Console.WriteLine("Mobile display creative with id \"{0}\" was created.",
                                  creativeSaveResult.id);
            } catch (Exception ex) {
                Console.WriteLine("Failed to create display creative. Exception says \"{0}\"",
                                  ex.Message);
            }
        }