Examples of CreativeServiceInterface


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

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

      // Get the CreativeService.
      CreativeServiceInterface creativeService =
          user.getService(DfpService.V201311.CREATIVE_SERVICE);

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

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

        // Get creatives by statement.
        page = creativeService.getCreativesByStatement(filterStatement);

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

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

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

      // Get the CreativeService.
      CreativeServiceInterface creativeService =
          user.getService(DfpService.V201311.CREATIVE_SERVICE);

      // Set the ID of the creative to get.
      Long creativeId = Long.parseLong("INSERT_CREATIVE_ID_HERE");

      // Get the creative.
      Creative creative = creativeService.getCreative(creativeId);

      if (creative != null) {
        System.out.println("Creative with ID \"" + creative.getId()
             + "\", name \"" + creative.getName()
             + "\", and type \"" + creative.getCreativeType() + "\" was found.");
View Full Code Here

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

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

      // Get the CreativeService.
      CreativeServiceInterface creativeService =
          user.getService(DfpService.V201311.CREATIVE_SERVICE);

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

      // Create an array to store local image creative objects.
      Creative[] imageCreatives = new ImageCreative[5];

      for (int i = 0; i < 5; i++) {
        // Create creative size.
        Size size = new Size();
        size.setWidth(300);
        size.setHeight(250);
        size.setIsAspectRatio(false);

        // Create an image creative.
        ImageCreative imageCreative = new ImageCreative();
        imageCreative.setName("Image creative #" + i);
        imageCreative.setAdvertiserId(advertiserId);
        imageCreative.setDestinationUrl("http://google.com");
        imageCreative.setSize(size);

        // Create image asset.
        CreativeAsset creativeAsset = new CreativeAsset();
        creativeAsset.setFileName("image.jpg");
        creativeAsset.setAssetByteArray(MediaUtils.getAssetDataFromUrl(
            "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg"));
        creativeAsset.setSize(size);
        imageCreative.setPrimaryImageAsset(creativeAsset);

        imageCreatives[i] = imageCreative;
      }

      // Create the image creatives on the server.
      imageCreatives = creativeService.createCreatives(imageCreatives);

      if (imageCreatives != null) {
        for (Creative creative : imageCreatives) {
          // Use instanceof to determine what type of creative was returned.
          if (creative instanceof ImageCreative) {
View Full Code Here

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

      // Get the LineItemCreativeAssociationService.
      LineItemCreativeAssociationServiceInterface licaService =
          user.getService(DfpService.V201311.LINEITEMCREATIVEASSOCIATION_SERVICE);

      // Get the CreativeService.
      CreativeServiceInterface creativeService =
          user.getService(DfpService.V201311.CREATIVE_SERVICE);

      // Set the line item ID and creative IDs to associate.
      Long lineItemId = Long.parseLong("INSERT_LINE_ITEM_ID_HERE");
      Long[] creativeIds = new Long[] {Long.parseLong("INSERT_CREATIVE_ID_HERE")};
View Full Code Here

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

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

      // Get the CreativeService.
      CreativeServiceInterface creativeService =
          user.getService(DfpService.V201311.CREATIVE_SERVICE);

      Long[] imageCreativeIds = new Long[] {Long.parseLong("INSERT_IMAGE_CREATIVE_ID_HERE")};

      // Create the statement to filter image creatives by id.
      StatementBuilder statementBuilder =
          new StatementBuilder("WHERE id IN ( " + StringUtils.join(imageCreativeIds, ',')
              + ") and creativeType = :creativeType LIMIT 500").putValue("creativeType",
              ImageCreative.class.getSimpleName());

      // Retrieve all creatives which match.
      CreativePage page =
          creativeService.getCreativesByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        Creative[] creatives = page.getResults();
        long[] oldIds = new long[creatives.length];
        for (int i = 0; i < creatives.length; i++) {
          ImageCreative imageCreative = (ImageCreative) creatives[i];
          oldIds[i] = imageCreative.getId();
          imageCreative.setId(null);
          imageCreative.setAdvertiserId(imageCreative.getAdvertiserId());
          imageCreative.setName(
              imageCreative.getName() + " (Copy #" + System.currentTimeMillis() + ")");

          // Create image asset.
          CreativeAsset creativeAsset = new CreativeAsset();
          creativeAsset.setFileName("image.jpg");
          creativeAsset.setAssetByteArray(
              MediaUtils.getAssetDataFromUrl(imageCreative.getPrimaryImageAsset().getAssetUrl()));
          creativeAsset.setSize(imageCreative.getPrimaryImageAsset().getSize());
          imageCreative.setPrimaryImageAsset(creativeAsset);

          creatives[i] = imageCreative;
        }

        // Create the copied creative.
        creatives = creativeService.createCreatives(creatives);

        // Display copied creatives.
        for (int i = 0; i < creatives.length; i++) {
          System.out.println("Image creative with ID \"" + oldIds[i] + "\" copied to ID \""
              + creatives[i].getId() + "\".");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.