Package com.google.api.ads.dfp.v201306

Examples of com.google.api.ads.dfp.v201306.CustomCreative


    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


    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

    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

    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

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

      return (Value) value;
    } else if (value == null) {
      return new TextValue(null, null);
    } else {
      if (value instanceof Boolean) {
        return new BooleanValue(null, (Boolean) value);
      } else if (value instanceof Double) {
        return new NumberValue(null, value.toString());
      } else if (value instanceof String) {
        return new TextValue(null, (String) value);
      } else if (value instanceof Long) {
View Full Code Here

      // Set the ID of the company to get.
      Long companyId = Long.parseLong("INSERT_COMPANY_ID_HERE");

      // Get the company.
      Company company = companyService.getCompany(companyId);

      if (company != null) {
        System.out.println("Company with ID \"" + company.getId()
            + "\", name \"" + company.getName()
            + "\", and type \"" + company.getType() + "\" was found.");
      } else {
        System.out.println("No company found for this ID.");
      }
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

      // Create an array to store local company objects.
      Company[] companies = new Company[5];

      for (int i = 0; i < 5; i++) {
        Company company = new Company();
        company.setName("Advertiser #" + i);
        company.setType(CompanyType.ADVERTISER);
        companies[i] = company;
      }

      // Create the companies on the server.
      companies = companyService.createCompanies(companies);

      if (companies != null) {
        for (Company company : companies) {
          System.out.println("A company with ID \"" + company.getId()
              + "\", name \"" + company.getName()
              + "\", and type \"" + company.getType() + "\" was created.");
        }
      } else {
        System.out.println("No companies created.");
      }
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.v201306.CustomCreative

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.