public static void updateAd()
        {
            AdServiceClient service = new AdServiceClient();

            AuthHeader authHeader = new AuthHeader();

            HeaderUtil.loadHeader(authHeader);

            AdType[] parameters = new AdType[1];
            parameters[0]                 = new AdType();
            parameters[0].adId            = 27108657L;
            parameters[0].adIdSpecified   = true;
            parameters[0].description1    = "描述1的文字内容-图文";
            parameters[0].description2    = "描述2的文字内容-图文";
            parameters[0].displayUrl      = "www.baidu.com";
            parameters[0].destinationUrl  = "http://www.baidu.com";
            parameters[0].imageData       = ImageUtils.GetImageDataFromFile("../../data/60_60.jpg");
            parameters[0].width           = 60;
            parameters[0].widthSpecified  = true;
            parameters[0].height          = 60;
            parameters[0].heightSpecified = true;
            parameters[0].title           = "创意标题内容-图文";
            parameters[0].type            = 5;
            parameters[0].typeSpecified   = true;

            ResHeader resHeader = service.updateAd(authHeader, ref parameters);

            Console.WriteLine("AdService.updateAd(): ");
            ObjectDumper.WriteResponse(resHeader, parameters);
        }
 /// <summary>Snippet for GetAd</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetAdResourceNames()
 {
     // Create client
     AdServiceClient adServiceClient = AdServiceClient.Create();
     // Initialize request argument(s)
     AdName resourceName = AdName.FromCustomerAd("[CUSTOMER]", "[AD]");
     // Make the request
     Ad response = adServiceClient.GetAd(resourceName);
 }
Beispiel #3
0
 /// <summary>Snippet for GetAd</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetAd()
 {
     // Create client
     AdServiceClient adServiceClient = AdServiceClient.Create();
     // Initialize request argument(s)
     string resourceName = "customers/[CUSTOMER]/ads/[AD]";
     // Make the request
     Ad response = adServiceClient.GetAd(resourceName);
 }
        /// <summary>Snippet for GetAdAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task GetAdAsync()
        {
            // Create client
            AdServiceClient adServiceClient = await AdServiceClient.CreateAsync();

            // Initialize request argument(s)
            string resourceName = "customers/[CUSTOMER_ID]/ads/[AD_ID]";
            // Make the request
            Ad response = await adServiceClient.GetAdAsync(resourceName);
        }
        /// <summary>Snippet for GetAdAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task GetAdResourceNamesAsync()
        {
            // Create client
            AdServiceClient adServiceClient = await AdServiceClient.CreateAsync();

            // Initialize request argument(s)
            AdName resourceName = AdName.FromCustomerAd("[CUSTOMER]", "[AD]");
            // Make the request
            Ad response = await adServiceClient.GetAdAsync(resourceName);
        }
 /// <summary>Snippet for MutateAds</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateAds()
 {
     // Create client
     AdServiceClient adServiceClient = AdServiceClient.Create();
     // Initialize request argument(s)
     string customerId = "";
     IEnumerable <AdOperation> operations = new AdOperation[] { new AdOperation(), };
     // Make the request
     MutateAdsResponse response = adServiceClient.MutateAds(customerId, operations);
 }
 /// <summary>Snippet for GetAd</summary>
 public void GetAd()
 {
     // Snippet: GetAd(string, CallSettings)
     // Create client
     AdServiceClient adServiceClient = AdServiceClient.Create();
     // Initialize request argument(s)
     string resourceName = "customers/[CUSTOMER_ID]/ads/[AD_ID]";
     // Make the request
     Ad response = adServiceClient.GetAd(resourceName);
     // End snippet
 }
 /// <summary>Snippet for GetAd</summary>
 public void GetAdResourceNames()
 {
     // Snippet: GetAd(AdName, CallSettings)
     // Create client
     AdServiceClient adServiceClient = AdServiceClient.Create();
     // Initialize request argument(s)
     AdName resourceName = AdName.FromCustomerAd("[CUSTOMER_ID]", "[AD_ID]");
     // Make the request
     Ad response = adServiceClient.GetAd(resourceName);
     // End snippet
 }
 /// <summary>Snippet for GetAd</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetAdRequestObject()
 {
     // Create client
     AdServiceClient adServiceClient = AdServiceClient.Create();
     // Initialize request argument(s)
     GetAdRequest request = new GetAdRequest
     {
         ResourceNameAsAdName = AdName.FromCustomerAd("[CUSTOMER]", "[AD]"),
     };
     // Make the request
     Ad response = adServiceClient.GetAd(request);
 }
Beispiel #10
0
 /// <summary>Snippet for MutateAds</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateAdsRequestObject()
 {
     // Create client
     AdServiceClient adServiceClient = AdServiceClient.Create();
     // Initialize request argument(s)
     MutateAdsRequest request = new MutateAdsRequest
     {
         CustomerId = "",
         Operations = { new AdOperation(), },
     };
     // Make the request
     MutateAdsResponse response = adServiceClient.MutateAds(request);
 }
        /// <summary>Snippet for GetAdAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task GetAdRequestObjectAsync()
        {
            // Create client
            AdServiceClient adServiceClient = await AdServiceClient.CreateAsync();

            // Initialize request argument(s)
            GetAdRequest request = new GetAdRequest
            {
                ResourceNameAsAdName = AdName.FromCustomerAd("[CUSTOMER_ID]", "[AD_ID]"),
            };
            // Make the request
            Ad response = await adServiceClient.GetAdAsync(request);
        }
        /// <summary>Snippet for GetAdAsync</summary>
        public async Task GetAdResourceNamesAsync()
        {
            // Snippet: GetAdAsync(AdName, CallSettings)
            // Additional: GetAdAsync(AdName, CancellationToken)
            // Create client
            AdServiceClient adServiceClient = await AdServiceClient.CreateAsync();

            // Initialize request argument(s)
            AdName resourceName = AdName.FromCustomerAd("[CUSTOMER_ID]", "[AD_ID]");
            // Make the request
            Ad response = await adServiceClient.GetAdAsync(resourceName);

            // End snippet
        }
        /// <summary>Snippet for MutateAdsAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task MutateAdsRequestObjectAsync()
        {
            // Create client
            AdServiceClient adServiceClient = await AdServiceClient.CreateAsync();

            // Initialize request argument(s)
            MutateAdsRequest request = new MutateAdsRequest
            {
                CustomerId = "",
                Operations = { new AdOperation(), },
            };
            // Make the request
            MutateAdsResponse response = await adServiceClient.MutateAdsAsync(request);
        }
        /// <summary>Snippet for GetAdAsync</summary>
        public async Task GetAdAsync()
        {
            // Snippet: GetAdAsync(string, CallSettings)
            // Additional: GetAdAsync(string, CancellationToken)
            // Create client
            AdServiceClient adServiceClient = await AdServiceClient.CreateAsync();

            // Initialize request argument(s)
            string resourceName = "customers/[CUSTOMER_ID]/ads/[AD_ID]";
            // Make the request
            Ad response = await adServiceClient.GetAdAsync(resourceName);

            // End snippet
        }
        /// <summary>Snippet for MutateAdsAsync</summary>
        public async Task MutateAdsAsync()
        {
            // Snippet: MutateAdsAsync(string, IEnumerable<AdOperation>, CallSettings)
            // Additional: MutateAdsAsync(string, IEnumerable<AdOperation>, CancellationToken)
            // Create client
            AdServiceClient adServiceClient = await AdServiceClient.CreateAsync();

            // Initialize request argument(s)
            string customerId = "";
            IEnumerable <AdOperation> operations = new AdOperation[] { new AdOperation(), };
            // Make the request
            MutateAdsResponse response = await adServiceClient.MutateAdsAsync(customerId, operations);

            // End snippet
        }
        public static void getAdByAdId()
        {
            AdServiceClient client = new AdServiceClient();

            AuthHeader authHeader = new AuthHeader();

            HeaderUtil.loadHeader(authHeader);

            AdType[] result = null;

            ResHeader resHeader = client.getAdByAdId(authHeader, new long[] { 27108656L, 27108657L }, out result);

            Console.WriteLine("AdService.getAdByAdId(): ");
            ObjectDumper.WriteResponse(resHeader, result);
        }
 /// <summary>Snippet for MutateAds</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateAdsRequestObject()
 {
     // Create client
     AdServiceClient adServiceClient = AdServiceClient.Create();
     // Initialize request argument(s)
     MutateAdsRequest request = new MutateAdsRequest
     {
         CustomerId          = "",
         Operations          = { new AdOperation(), },
         ValidateOnly        = false,
         PartialFailure      = false,
         ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified,
     };
     // Make the request
     MutateAdsResponse response = adServiceClient.MutateAds(request);
 }
 /// <summary>Snippet for MutateAds</summary>
 public void MutateAdsRequestObject()
 {
     // Snippet: MutateAds(MutateAdsRequest, CallSettings)
     // Create client
     AdServiceClient adServiceClient = AdServiceClient.Create();
     // Initialize request argument(s)
     MutateAdsRequest request = new MutateAdsRequest
     {
         CustomerId          = "",
         Operations          = { new AdOperation(), },
         ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified,
     };
     // Make the request
     MutateAdsResponse response = adServiceClient.MutateAds(request);
     // End snippet
 }
        public static void deleteAd()
        {
            AdServiceClient client = new AdServiceClient();

            AuthHeader authHeader = new AuthHeader();

            HeaderUtil.loadHeader(authHeader);

            long[] adids  = new long[] { 1055186 };
            string result = null;

            ResHeader resHeader = client.deleteAd(authHeader, adids, out result);

            Console.WriteLine("AdService.deleteAd(): ");
            ObjectDumper.WriteResponse(resHeader, result);
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        /// <param name="adId"> ID of the ad to update.</param>
        // [START update_expanded_text_ad]
        public void Run(GoogleAdsClient client, long customerId, long adId)
        {
            // Get the AdService.
            AdServiceClient adService = client.GetService(Services.V10.AdService);

            Ad ad = new Ad()
            {
                ResourceName   = ResourceNames.Ad(customerId, adId),
                ExpandedTextAd = new ExpandedTextAdInfo()
                {
                    // Update some properties of the expanded text ad.
                    HeadlinePart1 = "Cruise to Pluto #" + ExampleUtilities.GetShortRandomString(),
                    HeadlinePart2 = "Tickets on sale now",
                    Description   = "Best space cruise ever.",
                },
                FinalUrls       = { "http://www.example.com/" },
                FinalMobileUrls = { "http://www.example.com/mobile" }
            };

            AdOperation operation = new AdOperation()
            {
                Update     = ad,
                UpdateMask = FieldMasks.AllSetFieldsOf(ad)
            };

            try
            {
                // Issue the update request.
                MutateAdsResponse response = adService.MutateAds(customerId.ToString(),
                                                                 new[] { operation });

                // Display the results.
                foreach (MutateAdResult updatedAd in response.Results)
                {
                    Console.WriteLine($"Ad with resource ID = '{updatedAd.ResourceName}' was " +
                                      $"updated.");
                }
            }
            catch (GoogleAdsException e)
            {
                Console.WriteLine("Failure:");
                Console.WriteLine($"Message: {e.Message}");
                Console.WriteLine($"Failure: {e.Failure}");
                Console.WriteLine($"Request ID: {e.RequestId}");
                throw;
            }
        }
        public static void copyAd()
        {
            AdServiceClient service = new AdServiceClient();

            AuthHeader authHeader = new AuthHeader();

            HeaderUtil.loadHeader(authHeader);

            long[] adIds    = new long[] { 26876764L, 26874052L };
            long[] groupIds = new long[] { 2562221L, 2199683L };

            string    result    = null;
            ResHeader resHeader = service.copyAd(authHeader, groupIds, adIds, out result);

            Console.WriteLine("AdService.copyAd(): ");
            ObjectDumper.WriteResponse(resHeader, result);
        }
        public static void getAdIdByGroupId()
        {
            AdServiceClient client = new AdServiceClient();

            AuthHeader authHeader = new AuthHeader();

            HeaderUtil.loadHeader(authHeader);

            int groupId = 2562221;

            long[] result = null;

            ResHeader resHeader = client.getAdIdByGroupId(authHeader, groupId, out result);

            Console.WriteLine("AdService.getAdIdByGroupId(): ");
            ObjectDumper.WriteResponse(resHeader, result);
        }
        public static void replaceAd()
        {
            AdServiceClient service = new AdServiceClient();

            AuthHeader authHeader = new AuthHeader();

            HeaderUtil.loadHeader(authHeader);

            long[] adIds = new long[] { 26876764L, 26874052L };
            long   adId  = 27108657L;

            string    result    = null;
            ResHeader resHeader = service.replaceAd(authHeader, adIds, adId, out result);

            Console.WriteLine("AdService.replaceAd(): ");
            ObjectDumper.WriteResponse(resHeader, result);
        }
Beispiel #24
0
        /// <summary>Snippet for MutateAdsAsync</summary>
        public async Task MutateAdsRequestObjectAsync()
        {
            // Snippet: MutateAdsAsync(MutateAdsRequest, CallSettings)
            // Additional: MutateAdsAsync(MutateAdsRequest, CancellationToken)
            // Create client
            AdServiceClient adServiceClient = await AdServiceClient.CreateAsync();

            // Initialize request argument(s)
            MutateAdsRequest request = new MutateAdsRequest
            {
                CustomerId = "",
                Operations = { new AdOperation(), },
            };
            // Make the request
            MutateAdsResponse response = await adServiceClient.MutateAdsAsync(request);

            // End snippet
        }
        public static void addAd()
        {
            AdServiceClient service = new AdServiceClient();

            AuthHeader authHeader = new AuthHeader();

            HeaderUtil.loadHeader(authHeader);

            AdType[] parameters = new AdType[2];
            parameters[0]                  = new AdType();
            parameters[0].localId          = 1000001L;
            parameters[0].groupId          = 2562221L;
            parameters[0].groupIdSpecified = true;
            parameters[0].description1     = "描述1的文字内容";
            parameters[0].description2     = "描述2的文字内容";
            parameters[0].displayUrl       = "www.baidu.com";
            parameters[0].destinationUrl   = "http://www.baidu.com";
            parameters[0].title            = "创意标题内容";
            parameters[0].type             = 1;
            parameters[0].typeSpecified    = true;
            parameters[0].status           = 0;

            parameters[1]                  = new AdType();
            parameters[1].localId          = 1000002L;
            parameters[1].groupId          = 2562221L;
            parameters[1].groupIdSpecified = true;
            parameters[1].displayUrl       = "www.baidu.com";
            parameters[1].destinationUrl   = "http://www.baidu.com/targeturl";
            parameters[1].title            = "picture_name";
            parameters[1].type             = 2;
            parameters[1].typeSpecified    = true;
            parameters[1].status           = 0;
            parameters[1].imageData        = ImageUtils.GetImageDataFromFile("../../data/160_600.jpg");
            parameters[1].width            = 160;
            parameters[1].widthSpecified   = true;
            parameters[1].height           = 600;
            parameters[1].heightSpecified  = true;

            ResHeader resHeader = service.addAd(authHeader, ref parameters);

            Console.WriteLine("AdService.addAd(): ");
            ObjectDumper.WriteResponse(resHeader, parameters);
        }
        public static void setAdStatus()
        {
            AdServiceClient service = new AdServiceClient();

            AuthHeader authHeader = new AuthHeader();

            HeaderUtil.loadHeader(authHeader);

            StatusType[] status = new StatusType[1];
            status[0]        = new StatusType();
            status[0].adId   = 27108657L;
            status[0].status = 0;

            string    result    = null;
            ResHeader resHeader = service.setAdStatus(authHeader, status, out result);

            Console.WriteLine("AdService.setAdStatus(): ");
            ObjectDumper.WriteResponse(resHeader, result);
        }
        /// <summary>Snippet for MutateAdsAsync</summary>
        public async Task MutateAdsRequestObjectAsync()
        {
            // Snippet: MutateAdsAsync(MutateAdsRequest, CallSettings)
            // Additional: MutateAdsAsync(MutateAdsRequest, CancellationToken)
            // Create client
            AdServiceClient adServiceClient = await AdServiceClient.CreateAsync();

            // Initialize request argument(s)
            MutateAdsRequest request = new MutateAdsRequest
            {
                CustomerId          = "",
                Operations          = { new AdOperation(), },
                ValidateOnly        = false,
                PartialFailure      = false,
                ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified,
            };
            // Make the request
            MutateAdsResponse response = await adServiceClient.MutateAdsAsync(request);

            // End snippet
        }