// Copyright 2009, Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * This code sample creates a new text ad given an existing ad group. To create * an ad group, you can run AddAdGroup.cs. */ using SampleCode.com.google.sandbox.v13.AdService; using System; namespace SampleCode.v13 { public class DeleteTextAd { // Provide AdWords login information. private static String email = "INSERT_LOGIN_EMAIL_HERE"; private static String password = "INSERT_PASSWORD_HERE"; private static String clientEmail = "INSERT_CLIENT_LOGIN_EMAIL_HERE"; private static String useragent = "INSERT_COMPANY_NAME: AdWords API DotNet Sample Code"; private static String developerToken = "INSERT_DEVELOPER_TOKEN_HERE"; private static String applicationToken = "INSERT_APPLICATION_TOKEN_HERE"; public static void Main() { try { // Set up service connection. AdService service = new AdService(); // Define SOAP headers. service.emailValue = new email(); service.emailValue.Text = new String[] {email}; service.passwordValue = new password(); service.passwordValue.Text = new String[] {password}; service.clientEmailValue = new clientEmail(); service.clientEmailValue.Text = new String[] {clientEmail}; service.useragentValue = new useragent(); service.useragentValue.Text = new String[] {useragent}; service.developerTokenValue = new developerToken(); service.developerTokenValue.Text = new String[] {developerToken}; service.applicationTokenValue = new applicationToken(); service.applicationTokenValue.Text = new String[] {applicationToken}; // Create existing ad structure. long adGroupId = long.Parse("INSERT_AD_GROUP_ID_HERE"); long adId = long.Parse("INSERT_AD_ID_HERE"); TextAd textAd = new TextAd(); textAd.adGroupId = adGroupId; textAd.adType = AdType.TextAd; textAd.adTypeSpecified = true; textAd.id = adId; textAd.status = AdStatus.Disabled; textAd.statusSpecified = true; // Delete ad. service.updateAds(new Ad[] {textAd}); // Display deleted ad. Console.WriteLine("Ad with id \"" + adId + "\" was deleted."); } catch (Exception e) { Console.WriteLine(e); } } } }