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

Examples of com.google.api.ads.dfp.axis.v201311.NumberValue


  private static final String ADVERTISER_ID = "INSERT_ADVERTISER_COMPANY_ID_HERE";

  public static void runExample(DfpServices dfpServices, DfpSession session, long advertiserId)
      throws Exception {
    // Get the CreativeService.
    CreativeServiceInterface creativeService =
        dfpServices.get(session, CreativeServiceInterface.class);

    // Create creative size.
    Size size = new Size();
    size.setWidth(300);
    size.setHeight(250);
    size.setIsAspectRatio(false);

    // Create a custom creative.
    CustomCreative customCreative = new CustomCreative();
    customCreative.setName("Custom creative #" + new Random().nextInt(Integer.MAX_VALUE));
    customCreative.setAdvertiserId(advertiserId);
    customCreative.setDestinationUrl("http://google.com");
    customCreative.setSize(size);

    // Set the custom creative image asset.
    CustomCreativeAsset customCreativeAsset = new CustomCreativeAsset();
    customCreativeAsset.setMacroName("IMAGE_ASSET");
    customCreativeAsset.setAssetByteArray(Media.getMediaDataFromUrl(
        "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg"));
    // Filenames must be unique.
    customCreativeAsset.setFileName(
        String.format("image%s.jpg", new Random().nextInt(Integer.MAX_VALUE)));
    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!");

    // Create the creative on the server.
    Creative[] creatives =
        creativeService.createCreatives(new Creative[] {customCreative});

    for (Creative createdCreative : creatives) {
      System.out.printf("A creative with ID \"%d\", name \"%s\", and type \"%s\""
          + " was created and can be previewed at: %s\n", createdCreative.getId(),
          createdCreative.getName(), createdCreative.getCreativeType(),
View Full Code Here


  private static final String CREATIVE_ID = "INSERT_CREATIVE_ID_HERE";

  public static void runExample(DfpServices dfpServices, DfpSession session, long creativeId)
      throws Exception {
    // Get the CreativeService.
    CreativeServiceInterface creativeService =
        dfpServices.get(session, CreativeServiceInterface.class);

    // Create a statement to get the image creative.
    StatementBuilder statementBuilder = new StatementBuilder()
        .where("id = :id")
        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
        .withBindVariableValue("id", creativeId);

    // Get the creative.
    ImageCreative imageCreative = (ImageCreative) creativeService.getCreativesByStatement(
        statementBuilder.toStatement()).getResults()[0];

    // Modify existing image creative to copy it.
    imageCreative.setId(null);
    imageCreative.setName("Image creative copy #" + new Random().nextInt(Integer.MAX_VALUE));

    // Create copy of image asset.
    CreativeAsset creativeAsset = new CreativeAsset();
    creativeAsset.setFileName("image.jpg");
    creativeAsset.setAssetByteArray(Media.getMediaDataFromUrl(
        imageCreative.getPrimaryImageAsset().getAssetUrl()));
    creativeAsset.setSize(imageCreative.getPrimaryImageAsset().getSize());
    imageCreative.setPrimaryImageAsset(creativeAsset);

    // Create the creative on the server.
    Creative[] creatives =
        creativeService.createCreatives(new Creative[] {imageCreative});

    for (Creative createdCreative : creatives) {
      System.out.printf("A creative with ID \"%d\", name \"%s\", and type \"%s\""
          + " was created and can be previewed at: %s\n", createdCreative.getId(),
          createdCreative.getName(), createdCreative.getCreativeType(),
View Full Code Here

  private static final String ADVERTISER_ID = "INSERT_ADVERTISER_COMPANY_ID_HERE";

  public static void runExample(DfpServices dfpServices, DfpSession session, long advertiserId)
      throws Exception {
    // Get the CreativeService.
    CreativeServiceInterface creativeService =
        dfpServices.get(session, CreativeServiceInterface.class);

    // Create creative size.
    Size size = new Size();
    size.setWidth(300);
    size.setHeight(250);
    size.setIsAspectRatio(false);

    // Use the image banner with optional third party tracking template.
    // To determine what other creative templates exist,
    // run GetAllCreativeTemplates.java.
    long creativeTemplateId = 10000680L;

    // Create a template creative.
    TemplateCreative templateCreative = new TemplateCreative();
    templateCreative.setName("Template creative #" + new Random().nextInt(Integer.MAX_VALUE));
    templateCreative.setAdvertiserId(advertiserId);
    templateCreative.setCreativeTemplateId(creativeTemplateId);
    templateCreative.setSize(size);

    // Create the asset variable value.
    AssetCreativeTemplateVariableValue assetVariableValue =
        new AssetCreativeTemplateVariableValue();
    assetVariableValue.setUniqueName("Imagefile");
    assetVariableValue.setAssetByteArray(Media.getMediaDataFromUrl(
        "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg"));
    // Filenames must be unique.
    assetVariableValue.setFileName(
        String.format("image%s.jpg", new Random().nextInt(Integer.MAX_VALUE)));

    // Create the image width variable value.
    LongCreativeTemplateVariableValue imageWidthVariableValue =
        new LongCreativeTemplateVariableValue();
    imageWidthVariableValue.setUniqueName("Imagewidth");
    imageWidthVariableValue.setValue(300L);

    // Create the image height variable value.
    LongCreativeTemplateVariableValue imageHeightVariableValue =
        new LongCreativeTemplateVariableValue();
    imageHeightVariableValue.setUniqueName("Imageheight");
    imageHeightVariableValue.setValue(250L);

    // Create the URL variable value.
    UrlCreativeTemplateVariableValue urlVariableValue =
        new UrlCreativeTemplateVariableValue();
    urlVariableValue.setUniqueName("ClickthroughURL");
    urlVariableValue.setValue("www.google.com");

    // Create the target window variable value.
    StringCreativeTemplateVariableValue targetWindowVariableValue =
        new StringCreativeTemplateVariableValue();
    targetWindowVariableValue.setUniqueName("Targetwindow");
    targetWindowVariableValue.setValue("__blank");

    // Set the creative template variables.
    templateCreative.setCreativeTemplateVariableValues(new BaseCreativeTemplateVariableValue[] {
        assetVariableValue, imageWidthVariableValue, imageHeightVariableValue, urlVariableValue,
        targetWindowVariableValue});

    // Create the creative on the server.
    Creative[] creatives =
        creativeService.createCreatives(new Creative[] {templateCreative});

    for (Creative createdCreative : creatives) {
      System.out.printf("A creative with ID \"%d\", name \"%s\", and type \"%s\""
          + " was created and can be previewed at: %s\n", createdCreative.getId(),
          createdCreative.getName(), createdCreative.getCreativeType(),
View Full Code Here

    size.setWidth(300);
    size.setHeight(250);
    size.setIsAspectRatio(false);

    // Create a custom creative.
    CustomCreative customCreative = new CustomCreative();
    customCreative.setName("Custom creative #" + new Random().nextInt(Integer.MAX_VALUE));
    customCreative.setAdvertiserId(advertiserId);
    customCreative.setDestinationUrl("http://google.com");
    customCreative.setSize(size);

    // Set the custom creative image asset.
    CustomCreativeAsset customCreativeAsset = new CustomCreativeAsset();
    customCreativeAsset.setMacroName("IMAGE_ASSET");
    customCreativeAsset.setAssetByteArray(Media.getMediaDataFromUrl(
        "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg"));
    // Filenames must be unique.
    customCreativeAsset.setFileName(
        String.format("image%s.jpg", new Random().nextInt(Integer.MAX_VALUE)));
    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!");

    // Create the creative on the server.
    Creative[] creatives =
View Full Code Here

    customCreative.setAdvertiserId(advertiserId);
    customCreative.setDestinationUrl("http://google.com");
    customCreative.setSize(size);

    // Set the custom creative image asset.
    CustomCreativeAsset customCreativeAsset = new CustomCreativeAsset();
    customCreativeAsset.setMacroName("IMAGE_ASSET");
    customCreativeAsset.setAssetByteArray(Media.getMediaDataFromUrl(
        "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg"));
    // Filenames must be unique.
    customCreativeAsset.setFileName(
        String.format("image%s.jpg", new Random().nextInt(Integer.MAX_VALUE)));
    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!");

    // Create the creative on the server.
    Creative[] creatives =
        creativeService.createCreatives(new Creative[] {customCreative});
View Full Code Here

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

    // Only update the destination URL if it has one.
    if (creative instanceof HasDestinationUrlCreative) {
      HasDestinationUrlCreative hasDestinationUrlCreative = (HasDestinationUrlCreative) creative;

      // Update the destination URL of the creative.
      hasDestinationUrlCreative.setDestinationUrl("http://news.google.com");

      // Update the creative on the server.
      Creative[] creatives = creativeService.updateCreatives(new Creative[] {creative});

      for (Creative updatedCreative : creatives) {
View Full Code Here

    size.setWidth(300);
    size.setHeight(250);
    size.setIsAspectRatio(false);

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

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

    // Create an image redirect creative.
    ImageRedirectCreative imageRedirectCreative = new ImageRedirectCreative();
    imageRedirectCreative.setName(
        "Image redirect creative #" + new Random().nextInt(Integer.MAX_VALUE));
View Full Code Here

        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
        .withBindVariableValue("id", creativeId);

    // Get the creative.
    ImageCreative imageCreative = (ImageCreative) creativeService.getCreativesByStatement(
        statementBuilder.toStatement()).getResults()[0];

    // Modify existing image creative to copy it.
    imageCreative.setId(null);
    imageCreative.setName("Image creative copy #" + new Random().nextInt(Integer.MAX_VALUE));

    // Create copy of image asset.
    CreativeAsset creativeAsset = new CreativeAsset();
    creativeAsset.setFileName("image.jpg");
    creativeAsset.setAssetByteArray(Media.getMediaDataFromUrl(
        imageCreative.getPrimaryImageAsset().getAssetUrl()));
    creativeAsset.setSize(imageCreative.getPrimaryImageAsset().getSize());
    imageCreative.setPrimaryImageAsset(creativeAsset);

    // Create the creative on the server.
    Creative[] creatives =
        creativeService.createCreatives(new Creative[] {imageCreative});
View Full Code Here

        "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg"));
    creativeAsset.setSize(size);
    imageCreative.setPrimaryImageAsset(creativeAsset);

    // Create an image redirect creative.
    ImageRedirectCreative imageRedirectCreative = new ImageRedirectCreative();
    imageRedirectCreative.setName(
        "Image redirect creative #" + new Random().nextInt(Integer.MAX_VALUE));
    imageRedirectCreative.setAdvertiserId(advertiserId);
    imageRedirectCreative.setDestinationUrl("http://google.com");
    imageRedirectCreative.setImageUrl(
        "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg");
    imageRedirectCreative.setSize(size);

    // Create the creatives on the server.
    Creative[] creatives =
        creativeService.createCreatives(new Creative[] {imageCreative, imageRedirectCreative});
View Full Code Here

    // Filenames must be unique.
    assetVariableValue.setFileName(
        String.format("image%s.jpg", new Random().nextInt(Integer.MAX_VALUE)));

    // Create the image width variable value.
    LongCreativeTemplateVariableValue imageWidthVariableValue =
        new LongCreativeTemplateVariableValue();
    imageWidthVariableValue.setUniqueName("Imagewidth");
    imageWidthVariableValue.setValue(300L);

    // Create the image height variable value.
    LongCreativeTemplateVariableValue imageHeightVariableValue =
        new LongCreativeTemplateVariableValue();
    imageHeightVariableValue.setUniqueName("Imageheight");
    imageHeightVariableValue.setValue(250L);

    // Create the URL variable value.
    UrlCreativeTemplateVariableValue urlVariableValue =
        new UrlCreativeTemplateVariableValue();
    urlVariableValue.setUniqueName("ClickthroughURL");
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.axis.v201311.NumberValue

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.