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

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


      // 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

      // 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 master creative to get creative sets for.
      Long masterCreativeId = Long.parseLong("INSERT_MASTER_CREATIVE_ID_HERE");

      // Create statement object to only select creative sets that have the
      // given master creative.
      Statement filterStatement =
          new StatementBuilder("WHERE masterCreativeId = :masterCreativeId LIMIT 500")
              .putValue("masterCreativeId", masterCreativeId).toStatement();

      // Get creative sets by statement.
      CreativeSetPage 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

          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

              .putValue("status", CreativeWrapperStatus.ACTIVE.toString())
              .putValue("labelId", labelId)
              .toStatement();

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

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

        // Get creative wrappers by statement.
        page = creativeWrapperService.getCreativeWrappersByStatement(filterStatement);

        if (page.getResults() != null) {
          for (CreativeWrapper creativeWrapper: page.getResults()) {
            System.out.printf("%d) Creative wrapper with ID \"%s\" applying to label"
                + " \"%s\" will be deactivated.\n", i++, creativeWrapper.getId(),
                creativeWrapper.getLabelId());
            creativeWrapperIds.add(creativeWrapper.getId());
          }
        }

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

      System.out.println(
          "Number of creative wrappers to be deactivated: " + creativeWrapperIds.size());

      if (creativeWrapperIds.size() > 0) {
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

      // 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 statement text to select the active creative wrappers for the
      // given label.
      String statementText =
          "WHERE status = :status AND labelId = :labelId LIMIT 500";
      Statement filterStatement =
          new StatementBuilder(statementText)
              .putValue("status", CreativeWrapperStatus.ACTIVE.toString())
              .putValue("labelId", labelId)
              .toStatement();

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

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

        // Get creative wrappers by statement.
        page = creativeWrapperService.getCreativeWrappersByStatement(filterStatement);

        if (page.getResults() != null) {
          for (CreativeWrapper creativeWrapper: page.getResults()) {
            System.out.printf("%d) Creative wrapper with ID \"%s\" applying to label"
                + " \"%s\" will be deactivated.\n", i++, creativeWrapper.getId(),
                creativeWrapper.getLabelId());
            creativeWrapperIds.add(creativeWrapper.getId());
          }
        }

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

      System.out.println(
          "Number of creative wrappers to be deactivated: " + creativeWrapperIds.size());

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

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

        // Perform action.
        UpdateResult result =
            creativeWrapperService.performCreativeWrapperAction(action, filterStatement);

        // Display results.
        if (result != null && result.getNumChanges() > 0) {
          System.out.println("Number of creative wrappers deactivated: " + result.getNumChanges());
        } else {
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

      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));
View Full Code Here

TOP

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

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.