Google.Api.Ads.AdWords.Examples.CSharp.v201705.CreateAndAttachSharedKeywordSet.CreateSharedKeywordSet(AdWordsUser)

Here are the examples of the csharp api class Google.Api.Ads.AdWords.Examples.CSharp.v201705.CreateAndAttachSharedKeywordSet.CreateSharedKeywordSet(AdWordsUser) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Example 7

1. Example

Project: googleads-dotnet-lib
Source File: CreateAndAttachSharedKeywordSet.cs
public void Run(AdWordsUser user, long campaignId) {
      try {
        // Create a shared set.
        SharedSet sharedSet = CreateSharedKeywordSet(user);

        Console.WriteLine("Shared set with id = {0}, name = {1}, type = {2}, status = {3} " +
            "was created.", sharedSet.sharedSetId, sharedSet.name, sharedSet.type,
            sharedSet.status);

        // Add new keywords to the shared set.
        string[] keywordTexts = new string[] { "mars cruise", "mars hotels" };
        SharedCriterion[] sharedCriteria = AddKeywordsToSharedSet(user, sharedSet.sharedSetId,
            keywordTexts);
        foreach (SharedCriterion sharedCriterion in sharedCriteria) {
          Keyword keyword = sharedCriterion.criterion as Keyword;
          Console.WriteLine("Added keyword with id = {0}, text = {1}, matchtype = {2} to " +
              "shared set with id = {3}.", keyword.id, keyword.text, keyword.matchType,
              sharedSet.sharedSetId);
        }

        // Attach the shared set to the campaign.
        CampaignSharedSet attachedSharedSet = AttachSharedSetToCampaign(user, campaignId,
            sharedSet.sharedSetId);

        Console.WriteLine("Attached shared set with id = {0} to campaign id {1}.",
            attachedSharedSet.sharedSetId, attachedSharedSet.campaignId);
      } catch (Exception e) {
        throw new System.ApplicationException("Failed to create shared keyword set and attach " +
            "it to a campaign.", e);
      }
    }