Package com.google.api.ads.dfp.v201208

Examples of com.google.api.ads.dfp.v201208.AdUnit


    // Get the InventoryService.
    InventoryServiceInterface inventoryService =
        dfpServices.get(session, InventoryServiceInterface.class);

    // Get the ad unit.
    AdUnit adUnit = inventoryService.getAdUnit(adUnitId);

    // Add the size 468x60 to the ad unit.
    List<AdUnitSize> adUnitSizes = Lists.<AdUnitSize>newArrayList(adUnit.getAdUnitSizes());

    // Create a 480x60 web ad unit size.
    Size size = new Size();
    size.setWidth(468);
    size.setHeight(60);

    AdUnitSize adUnitSize = new AdUnitSize();
    adUnitSize.setSize(size);
    adUnitSize.setEnvironmentType(EnvironmentType.BROWSER);
    adUnitSizes.add(adUnitSize);

    // Update the ad unit sizes.
    adUnit.setAdUnitSizes(adUnitSizes.toArray(new AdUnitSize[] {}));

    // Update the ad unit on the server.
    AdUnit[] adUnits = inventoryService.updateAdUnits(new AdUnit[] {adUnit});

    for (AdUnit updatedAdUnit : adUnits) {
View Full Code Here


    // Get the NetworkService.
    NetworkServiceInterface networkService =
        dfpServices.get(session, NetworkServiceInterface.class);

    // Get the effective root ad unit.
    AdUnit effectiveRootAdUnit =
        inventoryService.getAdUnit(
            networkService.getCurrentNetwork().getEffectiveRootAdUnitId());

    // Get all ad units.
    List<AdUnit> adUnits = getAllAdUnits(dfpServices, session);
View Full Code Here

    videoAdUnitSize.setSize(videoSize);
    videoAdUnitSize.setCompanions(new AdUnitSize[] {webAdUnitSize});
    videoAdUnitSize.setEnvironmentType(EnvironmentType.VIDEO_PLAYER);

    // Create a web ad unit.
    AdUnit webAdUnit = new AdUnit();
    webAdUnit.setName("web_ad_unit_" + new Random().nextInt(Integer.MAX_VALUE));
    webAdUnit.setDescription(webAdUnit.getName());
    webAdUnit.setTargetPlatform(TargetPlatform.WEB);
    webAdUnit.setParentId(parentAdUnitId);
    webAdUnit.setTargetWindow(AdUnitTargetWindow.BLANK);
    webAdUnit.setAdUnitSizes(new AdUnitSize[]{webAdUnitSize});

    // Create a video ad unit.
    AdUnit videoAdUnit = new AdUnit();
    videoAdUnit.setName("video_ad_unit_" + new Random().nextInt(Integer.MAX_VALUE));
    videoAdUnit.setDescription(videoAdUnit.getName());
    videoAdUnit.setTargetPlatform(TargetPlatform.WEB);
    videoAdUnit.setParentId(parentAdUnitId);
    videoAdUnit.setTargetWindow(AdUnitTargetWindow.BLANK);
    videoAdUnit.setAdUnitSizes(new AdUnitSize[]{videoAdUnitSize});

    // Create the ad units on the server.
    AdUnit[] adUnits = inventoryService.createAdUnits(new AdUnit[] {webAdUnit, videoAdUnit});

    for (AdUnit adUnit : adUnits) {
View Full Code Here

    // Get the InventoryService.
    InventoryServiceInterface inventoryService =
        dfpServices.get(session, InventoryServiceInterface.class);

    // Get the ad unit.
    AdUnit adUnit = inventoryService.getAdUnit(adUnitId);

    // Add the size 468x60 to the ad unit.
    List<AdUnitSize> adUnitSizes = Lists.<AdUnitSize>newArrayList(adUnit.getAdUnitSizes());

    // Create a 480x60 web ad unit size.
    Size size = new Size();
    size.setWidth(468);
    size.setHeight(60);

    AdUnitSize adUnitSize = new AdUnitSize();
    adUnitSize.setSize(size);
    adUnitSize.setEnvironmentType(EnvironmentType.BROWSER);
    adUnitSizes.add(adUnitSize);

    // Update the ad unit sizes.
    adUnit.setAdUnitSizes(adUnitSizes.toArray(new AdUnitSize[] {}));

    // Update the ad unit on the server.
    AdUnit[] adUnits = inventoryService.updateAdUnits(new AdUnit[] {adUnit});

    for (AdUnit updatedAdUnit : adUnits) {
View Full Code Here

    // Get the NetworkService.
    NetworkServiceInterface networkService =
        dfpServices.get(session, NetworkServiceInterface.class);

    // Get the effective root ad unit.
    AdUnit effectiveRootAdUnit =
        inventoryService.getAdUnit(
            networkService.getCurrentNetwork().getEffectiveRootAdUnitId());

    // Get all ad units.
    List<AdUnit> adUnits = getAllAdUnits(dfpServices, session);
View Full Code Here

    videoAdUnitSize.setSize(videoSize);
    videoAdUnitSize.setCompanions(new AdUnitSize[] {webAdUnitSize});
    videoAdUnitSize.setEnvironmentType(EnvironmentType.VIDEO_PLAYER);

    // Create a web ad unit.
    AdUnit webAdUnit = new AdUnit();
    webAdUnit.setName("web_ad_unit_" + new Random().nextInt(Integer.MAX_VALUE));
    webAdUnit.setDescription(webAdUnit.getName());
    webAdUnit.setTargetPlatform(TargetPlatform.WEB);
    webAdUnit.setParentId(parentAdUnitId);
    webAdUnit.setTargetWindow(AdUnitTargetWindow.BLANK);
    webAdUnit.setAdUnitSizes(new AdUnitSize[]{webAdUnitSize});

    // Create a video ad unit.
    AdUnit videoAdUnit = new AdUnit();
    videoAdUnit.setName("video_ad_unit_" + new Random().nextInt(Integer.MAX_VALUE));
    videoAdUnit.setDescription(videoAdUnit.getName());
    videoAdUnit.setTargetPlatform(TargetPlatform.WEB);
    videoAdUnit.setParentId(parentAdUnitId);
    videoAdUnit.setTargetWindow(AdUnitTargetWindow.BLANK);
    videoAdUnit.setAdUnitSizes(new AdUnitSize[]{videoAdUnitSize});

    // Create the ad units on the server.
    AdUnit[] adUnits = inventoryService.createAdUnits(new AdUnit[] {webAdUnit, videoAdUnit});

    for (AdUnit adUnit : adUnits) {
View Full Code Here

    // Get the InventoryService.
    InventoryServiceInterface inventoryService =
        dfpServices.get(session, InventoryServiceInterface.class);

    // Get the ad unit.
    AdUnit adUnit = inventoryService.getAdUnit(adUnitId);

    // Add the size 468x60 to the ad unit.
    List<AdUnitSize> adUnitSizes = Lists.<AdUnitSize>newArrayList(adUnit.getAdUnitSizes());

    // Create a 480x60 web ad unit size.
    Size size = new Size();
    size.setWidth(468);
    size.setHeight(60);

    AdUnitSize adUnitSize = new AdUnitSize();
    adUnitSize.setSize(size);
    adUnitSize.setEnvironmentType(EnvironmentType.BROWSER);
    adUnitSizes.add(adUnitSize);

    // Update the ad unit sizes.
    adUnit.setAdUnitSizes(adUnitSizes.toArray(new AdUnitSize[] {}));

    // Update the ad unit on the server.
    AdUnit[] adUnits = inventoryService.updateAdUnits(new AdUnit[] {adUnit});

    for (AdUnit updatedAdUnit : adUnits) {
View Full Code Here

    // Get the NetworkService.
    NetworkServiceInterface networkService =
        dfpServices.get(session, NetworkServiceInterface.class);

    // Get the effective root ad unit.
    AdUnit effectiveRootAdUnit =
        inventoryService.getAdUnit(
            networkService.getCurrentNetwork().getEffectiveRootAdUnitId());

    // Get all ad units.
    List<AdUnit> adUnits = getAllAdUnits(dfpServices, session);
View Full Code Here

      // Create an array to store local ad unit objects.
      AdUnit[] adUnits = new AdUnit[5];

      for (int i = 0; i < 5; i++) {
        AdUnit adUnit = new AdUnit();
        adUnit.setName("Ad_Unit_" + i);
        adUnit.setParentId(effectiveRootAdUnitId);
        adUnit.setDescription("Ad unit description.");
        adUnit.setTargetWindow(AdUnitTargetWindow.BLANK);

        // Create ad unit size.
        AdUnitSize adUnitSize = new AdUnitSize();
        adUnitSize.setSize(new Size(300, 250, false));
        adUnitSize.setEnvironmentType(EnvironmentType.BROWSER);

        // Set the size of possible creatives that can match this ad unit.
        adUnit.setAdUnitSizes(new AdUnitSize[] {adUnitSize});

        adUnits[i] = adUnit;
      }

      // Create the ad units on the server.
      adUnits = inventoryService.createAdUnits(adUnits);

      if (adUnits != null) {
        for (AdUnit adUnit : adUnits) {
          System.out.println("An ad unit with ID \"" + adUnit.getId()
              + "\" was created under parent with ID \"" + adUnit.getParentId()
              + "\".");
        }
      } else {
        System.out.println("No ad units created.");
      }
View Full Code Here

      // Set the parent ad unit's ID for all ad units to be created under.
      String effectiveRootAdUnitId = networkService.getCurrentNetwork().getEffectiveRootAdUnitId();

      // Create local ad unit object.
      AdUnit adUnit = new AdUnit();
      adUnit.setName("Mobile_Ad_Unit");
      adUnit.setParentId(effectiveRootAdUnitId);
      adUnit.setDescription("Ad unit description.");
      adUnit.setTargetWindow(AdUnitTargetWindow.BLANK);
      adUnit.setTargetPlatform(TargetPlatform.MOBILE);
      adUnit.setMobilePlatform(MobilePlatform.APPLICATION);

      // Create ad unit size.
      AdUnitSize adUnitSize = new AdUnitSize();
      adUnitSize.setSize(new Size(400, 300, false));
      adUnitSize.setEnvironmentType(EnvironmentType.BROWSER);

      // Set the size of possible creatives that can match this ad unit.
      adUnit.setAdUnitSizes(new AdUnitSize[] {adUnitSize});

      // Create the ad unit on the server.
      adUnit = inventoryService.createAdUnit(adUnit);

      if (adUnit != null) {
        System.out.println("An ad unit with ID \"" + adUnit.getId()
            + "\" was created under parent with ID \"" + adUnit.getParentId()
            + "\".");
      } else {
        System.out.println("No ad units created.");
      }
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.v201208.AdUnit

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.