示例#1
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public override void Run(DfpUser user)
        {
            // Create the CreativeWrapperService.
            CreativeWrapperService creativeWrapperService = (CreativeWrapperService)user.GetService(
                DfpService.v201405.CreativeWrapperService);

            long labelId = long.Parse(_T("INSERT_CREATIVE_WRAPPER_LABEL_ID_HERE"));

            // Create creative wrapper objects.
            CreativeWrapper creativeWrapper = new CreativeWrapper();

            creativeWrapper.labelId            = labelId;
            creativeWrapper.ordering           = CreativeWrapperOrdering.INNER;
            creativeWrapper.header             = new CreativeWrapperHtmlSnippet();
            creativeWrapper.header.htmlSnippet = "<b>My creative wrapper header</b>";
            creativeWrapper.footer             = new CreativeWrapperHtmlSnippet();
            creativeWrapper.footer.htmlSnippet = "<b>My creative wrapper footer</b>";

            try {
                // Add creative wrapper.
                CreativeWrapper[] creativeWrappers = creativeWrapperService.createCreativeWrappers(
                    new CreativeWrapper[] { creativeWrapper });

                // Display results.
                foreach (CreativeWrapper wrapper in creativeWrappers)
                {
                    Console.WriteLine("Creative wrapper with ID \'{0}\' applying to label \'{1}\' was " +
                                      "created.", wrapper.id, wrapper.labelId);
                }
            } catch (Exception ex) {
                Console.WriteLine("Failed to create creative wrappers. Exception says \"{0}\"", ex.Message);
            }
        }
示例#2
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        public void Run(AdManagerUser user)
        {
            using (CreativeWrapperService creativeWrapperService =
                       user.GetService <CreativeWrapperService>())
            {
                long labelId = long.Parse(_T("INSERT_CREATIVE_WRAPPER_LABEL_ID_HERE"));

                // Create creative wrapper objects.
                CreativeWrapper creativeWrapper = new CreativeWrapper();
                creativeWrapper.labelId    = labelId;
                creativeWrapper.ordering   = CreativeWrapperOrdering.INNER;
                creativeWrapper.htmlHeader = "<b>My creative wrapper header</b>";
                creativeWrapper.htmlFooter = "<b>My creative wrapper footer</b>";

                try
                {
                    // Add creative wrapper.
                    CreativeWrapper[] creativeWrappers =
                        creativeWrapperService.createCreativeWrappers(new CreativeWrapper[]
                    {
                        creativeWrapper
                    });

                    // Display results.
                    foreach (CreativeWrapper wrapper in creativeWrappers)
                    {
                        Console.WriteLine(
                            "Creative wrapper with ID '{0}' applying to label '{1}' was " +
                            "created.", wrapper.id, wrapper.labelId);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed to create creative wrappers. Exception says \"{0}\"",
                                      e.Message);
                }
            }
        }