Package com.google.api.ads.dfp.v201311

Examples of com.google.api.ads.dfp.v201311.User


      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the CreativeSetService.
      CreativeSetServiceInterface creativeSetService =
          user.getService(DfpService.V201311.CREATIVE_SET_SERVICE);

      // Set the ID of the creative set to get and the companion creative to
      // add.
      Long creativeSetId = Long.parseLong("INSERT_CREATIVE_SET_ID_HERE");
      Long companionCreativeId = Long.parseLong("INSERT_COMPANION_CREATIVE_ID_HERE");

      // Get the creative set.
      CreativeSet creativeSet = creativeSetService.getCreativeSet(creativeSetId);

      // Add the companion creative to the creative set.
      creativeSet.setCompanionCreativeIds(ArrayUtils.add(creativeSet.getCompanionCreativeIds(),
          companionCreativeId));

      // Update the creative set on the server.
      creativeSet = creativeSetService.updateCreativeSet(creativeSet);

      // Display results.
      System.out.println("A creative set with ID \"" + creativeSet.getId()
          + "\", master creative ID \"" + creativeSet.getMasterCreativeId()
          + "\", and companion creative IDs {"
View Full Code Here


      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the CreativeSetService.
      CreativeSetServiceInterface creativeSetService =
          user.getService(DfpService.V201311.CREATIVE_SET_SERVICE);

      // Set defaults for page and filterStatement.
      CreativeSetPage page = new CreativeSetPage();
      Statement filterStatement = new Statement();
      int offset = 0;

      do {
        // Create a statement to get all creative sets.
        filterStatement.setQuery("LIMIT 500 OFFSET " + offset);

        // Get creative sets by statement.
        page = creativeSetService.getCreativeSetsByStatement(filterStatement);

        if (page.getResults() != null) {
          int i = page.getStartIndex();
          for (CreativeSet creativeSet : page.getResults()) {
            System.out.println(i + ") Creative set with ID \"" + creativeSet.getId()
View Full Code Here

      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the CreativeSetService.
      CreativeSetServiceInterface creativeSetService =
          user.getService(DfpService.V201311.CREATIVE_SET_SERVICE);

      // Set the ID of the creatives to associate with this set.
      Long masterCreativeId = Long.parseLong("INSERT_MASTER_CREATIVE_ID_HERE");
      Long companionCreativeId = Long.parseLong("INSERT_COMPANION_CREATIVE_ID_HERE");

      CreativeSet creativeSet = new CreativeSet();
      creativeSet.setName("Creative set #" + new Random().nextLong());
      creativeSet.setMasterCreativeId(masterCreativeId);
      creativeSet.setCompanionCreativeIds(new long[] {companionCreativeId});

      // Create the creative set on the server.
      creativeSet = creativeSetService.createCreativeSet(creativeSet);

      if (creativeSet != null) {
        System.out.println("A creative set with ID \"" + creativeSet.getId()
            + "\", master creative ID \"" + creativeSet.getMasterCreativeId()
            + "\", and companion creative IDs {"
View Full Code Here

          user.getService(DfpService.V201311.CREATIVE_WRAPPER_SERVICE);

      Long labelId = Long.parseLong("INSERT_CREATIVE_WRAPPER_LABEL_ID_HERE");
     
      // Create a creative wrapper.
      CreativeWrapper creativeWrapper1 = new CreativeWrapper();
      // A label can only be associated with one creative wrapper.
      creativeWrapper1.setLabelId(labelId);
      creativeWrapper1.setOrdering(CreativeWrapperOrdering.INNER);
      creativeWrapper1.setHeader(
          new CreativeWrapperHtmlSnippet("<b>My creative wrapper header</b>"));
      creativeWrapper1.setFooter(
          new CreativeWrapperHtmlSnippet("<b>My creative wrapper footer</b>"));

      // Create the creative wrappers on the server.
      CreativeWrapper[] creativeWrappers =
          creativeWrapperService.createCreativeWrappers(new CreativeWrapper[] {creativeWrapper1});
View Full Code Here

      CreativeWrapper creativeWrapper1 = new CreativeWrapper();
      // A label can only be associated with one creative wrapper.
      creativeWrapper1.setLabelId(labelId);
      creativeWrapper1.setOrdering(CreativeWrapperOrdering.INNER);
      creativeWrapper1.setHeader(
          new CreativeWrapperHtmlSnippet("<b>My creative wrapper header</b>"));
      creativeWrapper1.setFooter(
          new CreativeWrapperHtmlSnippet("<b>My creative wrapper footer</b>"));

      // Create the creative wrappers on the server.
      CreativeWrapper[] creativeWrappers =
          creativeWrapperService.createCreativeWrappers(new CreativeWrapper[] {creativeWrapper1});
View Full Code Here

      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the CreativeWrapperService.
      CreativeWrapperServiceInterface creativeWrapperService =
          user.getService(DfpService.V201311.CREATIVE_WRAPPER_SERVICE);

      Long labelId = Long.parseLong("INSERT_CREATIVE_WRAPPER_LABEL_ID_HERE");
     
      // Create a creative wrapper.
      CreativeWrapper creativeWrapper1 = new CreativeWrapper();
      // A label can only be associated with one creative wrapper.
      creativeWrapper1.setLabelId(labelId);
      creativeWrapper1.setOrdering(CreativeWrapperOrdering.INNER);
      creativeWrapper1.setHeader(
          new CreativeWrapperHtmlSnippet("<b>My creative wrapper header</b>"));
      creativeWrapper1.setFooter(
          new CreativeWrapperHtmlSnippet("<b>My creative wrapper footer</b>"));

      // Create the creative wrappers on the server.
      CreativeWrapper[] creativeWrappers =
          creativeWrapperService.createCreativeWrappers(new CreativeWrapper[] {creativeWrapper1});

      for (CreativeWrapper creativeWrapper : creativeWrappers) {
        System.out.printf(
            "Creative wrapper with ID \"%s\" applying to label \"%s\" was created.\n",
            creativeWrapper.getId(), creativeWrapper.getLabelId());
View Full Code Here

      // Set the ID of the advertiser (company) that all creatives will be
      // assigned to.
      Long advertiserId = Long.parseLong("INSERT_ADVERTISER_COMPANY_ID_HERE");

      // Create the local custom creative object.
      CustomCreative customCreative = new CustomCreative();
      customCreative.setName("Custom creative");
      customCreative.setAdvertiserId(advertiserId);
      customCreative.setDestinationUrl("http://google.com");

      // Set the custom creative image asset.
      CustomCreativeAsset customCreativeAsset = new CustomCreativeAsset();
      customCreativeAsset.setMacroName("IMAGE_ASSET");
      customCreativeAsset.setAssetByteArray(MediaUtils.getAssetDataFromUrl(
          "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg"));
      // Filenames must be unique.
      customCreativeAsset.setFileName(String.format("image%s.jpg", System.currentTimeMillis()));
      customCreative.setCustomCreativeAssets(new CustomCreativeAsset[] {customCreativeAsset});

      // Set the HTML snippet using the custom creative asset macro.
      customCreative.setHtmlSnippet("<a href='%%CLICK_URL_UNESC%%%%DEST_URL%%'>" +
          "<img src='%%FILE:" + customCreativeAsset.getMacroName() + "%%'/>" +
          "</a><br>Click above for great deals!");

      // Set the creative size.
      customCreative.setSize(new Size(300, 250, false));

      // Create the custom creative on the server.
      customCreative = (CustomCreative) creativeService.createCreative(customCreative);

      if (customCreative != null) {
        System.out.println("A custom creative with ID \"" + customCreative.getId()
            + "\", name \"" + customCreative.getName()
            + "\", and size {" + customCreative.getSize().getWidth()
            + ", " + customCreative.getSize().getHeight() + "} was created and\n"
            + " can be previewed at: " + customCreative.getPreviewUrl());
      } else {
        System.out.println("No creative created.");
      }
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

      // Set the ID of the custom field to update.
      Long customFieldId = Long.parseLong("INSERT_CUSTOM_FIELD_ID_HERE");

      // Get the custom field.
      CustomField customField = customFieldService.getCustomField(customFieldId);

      if (customField != null) {
        customField.setDescription(customField.getDescription() == null ? "" : customField
            .getDescription() + " Updated");

        // Update the custom field on the server.
        CustomField[] customFields =
            customFieldService.updateCustomFields(new CustomField[] {customField});
View Full Code Here

      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the CustomFieldService.
      CustomFieldServiceInterface customFieldService =
          user.getService(DfpService.V201311.CUSTOM_FIELD_SERVICE);

      // Create statement to select only active custom fields that apply to
      // line items.
      String statementText =
          "WHERE entityType = :entityType and isActive = :isActive LIMIT 500";
      Statement filterStatement =
          new StatementBuilder(statementText)
              .putValue("entityType", CustomFieldEntityType.LINE_ITEM.toString())
              .putValue("isActive", true)
              .toStatement();

      // Set defaults for page and offset.
      CustomFieldPage page = new CustomFieldPage();
      int offset = 0;
      int i = 0;
      List<Long> customFieldIds = new ArrayList<Long>();

      do {
        // Create a statement to page through custom fields.
        filterStatement.setQuery(statementText + " OFFSET " + offset);

        // Get custom fields by statement.
        page = customFieldService.getCustomFieldsByStatement(filterStatement);

        if (page.getResults() != null) {
          for (CustomField customField : page.getResults()) {
            System.out.println(i + ") Custom field with ID \""
                + customField.getId() + "\" and name \"" + customField.getName()
                + "\" will be deactivated.");
            customFieldIds.add(customField.getId());
            i++;
          }
        }

        offset += 500;
      } while (offset < page.getTotalResultSetSize());

      System.out.println("Number of custom fields to be deactivated: " + customFieldIds.size());

      if (customFieldIds.size() > 0) {
        // Modify statement for action.
        filterStatement.setQuery("WHERE id IN (" + StringUtils.join(customFieldIds, ",") + ")");

        // Create action.
        DeactivateCustomFields action = new DeactivateCustomFields();

        // Perform action.
        UpdateResult result = customFieldService.performCustomFieldAction(action, filterStatement);

        // Display results.
        if (result != null && result.getNumChanges() > 0) {
          System.out.println("Number of custom fields deactivated: " + result.getNumChanges());
        } else {
View Full Code Here

      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the CustomFieldService.
      CustomFieldServiceInterface customFieldService =
          user.getService(DfpService.V201311.CUSTOM_FIELD_SERVICE);

      // Set the ID of the custom field to update.
      Long customFieldId = Long.parseLong("INSERT_CUSTOM_FIELD_ID_HERE");

      // Get the custom field.
      CustomField customField = customFieldService.getCustomField(customFieldId);

      if (customField != null) {
        customField.setDescription(customField.getDescription() == null ? "" : customField
            .getDescription() + " Updated");

        // Update the custom field on the server.
        CustomField[] customFields =
            customFieldService.updateCustomFields(new CustomField[] {customField});

        // Display results
        if (customFields != null) {
          for (CustomField updatedCustomField : customFields) {
            System.out.println("Custom field with ID \"" + updatedCustomField.getId()
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.v201311.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.