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

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


      // Set the ID of the placement to get.
      Long placementId = Long.parseLong("INSERT_PLACEMENT_ID_HERE");

      // Get the placement.
      Placement placement = placementService.getPlacement(placementId);

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


      // Get the PlacementService.
      PlacementServiceInterface placementService =
          user.getService(DfpService.V201208.PLACEMENT_SERVICE);

      // Create local placement object to store skyscraper ad units.
      Placement skyscraperAdUnitPlacement = new Placement();
      skyscraperAdUnitPlacement.setName("Skyscraper AdUnit Placement #"
          + System.currentTimeMillis());
      skyscraperAdUnitPlacement.setDescription(
          "Contains ad units that can hold creatives of size 120x600");
      skyscraperAdUnitPlacement.setTargetedAdUnitIds(new String[] {});

      // Create local placement object to store medium square ad units.
      Placement mediumSquareAdUnitPlacement = new Placement();
      mediumSquareAdUnitPlacement.setName("Medium Square AdUnit Placement #"
          + System.currentTimeMillis());
      mediumSquareAdUnitPlacement.setDescription(
          "Contains ad units that can hold creatives of size 300x250");
      mediumSquareAdUnitPlacement.setTargetedAdUnitIds(new String[] {});

      // Create local placement object to store banner ad units.
      Placement bannerAdUnitPlacement = new Placement();
      bannerAdUnitPlacement.setName("Banner AdUnit Placement #"
          + System.currentTimeMillis());
      bannerAdUnitPlacement.setDescription(
          "Contains ad units that can hold creatives of size 468x60");
      bannerAdUnitPlacement.setTargetedAdUnitIds(new String[] {});

      List<Placement> placementList = new ArrayList<Placement>();

      // Get the first 500 ad units.
      AdUnitPage page = inventoryService.getAdUnitsByStatement(new Statement("LIMIT 500", null));

      // Separate the ad units by size.
      if (page.getResults() != null) {
        for (AdUnit adUnit : page.getResults()) {
          if (adUnit.getParentId() != null && adUnit.getAdUnitSizes() != null) {
            for (AdUnitSize adUnitSize : adUnit.getAdUnitSizes()) {
              Size size = adUnitSize.getSize();
              if (size.getWidth() == 300 && size.getHeight() == 250) {
                Set<String> adUnitIds =
                    new HashSet<String>(Arrays.asList(
                        mediumSquareAdUnitPlacement.getTargetedAdUnitIds()));
                adUnitIds.add(adUnit.getId());
                mediumSquareAdUnitPlacement.setTargetedAdUnitIds(
                    adUnitIds.toArray(new String[] {}));
              } else if (size.getWidth() == 120 && size.getHeight() == 600) {
                Set<String> adUnitIds =
                    new HashSet<String>(Arrays.asList(
                        skyscraperAdUnitPlacement.getTargetedAdUnitIds()));
                adUnitIds.add(adUnit.getId());
                skyscraperAdUnitPlacement.setTargetedAdUnitIds(adUnitIds.toArray(new String[] {}));
              } else if (size.getWidth() == 468 && size.getHeight() == 60) {
                Set<String> adUnitIds =
                    new HashSet<String>(
                       Arrays.asList(bannerAdUnitPlacement.getTargetedAdUnitIds()));
                adUnitIds.add(adUnit.getId());
                bannerAdUnitPlacement.setTargetedAdUnitIds(adUnitIds.toArray(new String[] {}));
              }
            }
          }
        }
      }

      // Only create placements with one or more ad unit.
      if (mediumSquareAdUnitPlacement.getTargetedAdUnitIds().length != 0) {
        placementList.add(mediumSquareAdUnitPlacement);
      }

      if (skyscraperAdUnitPlacement.getTargetedAdUnitIds().length != 0) {
        placementList.add(skyscraperAdUnitPlacement);
      }

      if (bannerAdUnitPlacement.getTargetedAdUnitIds().length != 0) {
        placementList.add(bannerAdUnitPlacement);
      }

      // Create the placements on the server.
      Placement[] placements =
View Full Code Here

      // Set the ID of the placement to get.
      Long placementId = Long.parseLong("INSERT_PLACEMENT_ID_HERE");

      // Get the placement.
      Placement placement = placementService.getPlacement(placementId);

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

      // Get the PlacementService.
      PlacementServiceInterface placementService =
          user.getService(DfpService.V201211.PLACEMENT_SERVICE);

      // Create local placement object to store skyscraper ad units.
      Placement skyscraperAdUnitPlacement = new Placement();
      skyscraperAdUnitPlacement.setName("Skyscraper AdUnit Placement #"
          + System.currentTimeMillis());
      skyscraperAdUnitPlacement.setDescription(
          "Contains ad units that can hold creatives of size 120x600");
      skyscraperAdUnitPlacement.setTargetedAdUnitIds(new String[] {});

      // Create local placement object to store medium square ad units.
      Placement mediumSquareAdUnitPlacement = new Placement();
      mediumSquareAdUnitPlacement.setName("Medium Square AdUnit Placement #"
          + System.currentTimeMillis());
      mediumSquareAdUnitPlacement.setDescription(
          "Contains ad units that can hold creatives of size 300x250");
      mediumSquareAdUnitPlacement.setTargetedAdUnitIds(new String[] {});

      // Create local placement object to store banner ad units.
      Placement bannerAdUnitPlacement = new Placement();
      bannerAdUnitPlacement.setName("Banner AdUnit Placement #"
          + System.currentTimeMillis());
      bannerAdUnitPlacement.setDescription(
          "Contains ad units that can hold creatives of size 468x60");
      bannerAdUnitPlacement.setTargetedAdUnitIds(new String[] {});

      List<Placement> placementList = new ArrayList<Placement>();

      // Get the first 500 ad units.
      AdUnitPage page = inventoryService.getAdUnitsByStatement(new Statement("LIMIT 500", null));

      // Separate the ad units by size.
      if (page.getResults() != null) {
        for (AdUnit adUnit : page.getResults()) {
          if (adUnit.getParentId() != null && adUnit.getAdUnitSizes() != null) {
            for (AdUnitSize adUnitSize : adUnit.getAdUnitSizes()) {
              Size size = adUnitSize.getSize();
              if (size.getWidth() == 300 && size.getHeight() == 250) {
                Set<String> adUnitIds =
                    new HashSet<String>(Arrays.asList(
                        mediumSquareAdUnitPlacement.getTargetedAdUnitIds()));
                adUnitIds.add(adUnit.getId());
                mediumSquareAdUnitPlacement.setTargetedAdUnitIds(
                    adUnitIds.toArray(new String[] {}));
              } else if (size.getWidth() == 120 && size.getHeight() == 600) {
                Set<String> adUnitIds =
                    new HashSet<String>(Arrays.asList(
                        skyscraperAdUnitPlacement.getTargetedAdUnitIds()));
                adUnitIds.add(adUnit.getId());
                skyscraperAdUnitPlacement.setTargetedAdUnitIds(adUnitIds.toArray(new String[] {}));
              } else if (size.getWidth() == 468 && size.getHeight() == 60) {
                Set<String> adUnitIds =
                    new HashSet<String>(
                       Arrays.asList(bannerAdUnitPlacement.getTargetedAdUnitIds()));
                adUnitIds.add(adUnit.getId());
                bannerAdUnitPlacement.setTargetedAdUnitIds(adUnitIds.toArray(new String[] {}));
              }
            }
          }
        }
      }

      // Only create placements with one or more ad unit.
      if (mediumSquareAdUnitPlacement.getTargetedAdUnitIds().length != 0) {
        placementList.add(mediumSquareAdUnitPlacement);
      }

      if (skyscraperAdUnitPlacement.getTargetedAdUnitIds().length != 0) {
        placementList.add(skyscraperAdUnitPlacement);
      }

      if (bannerAdUnitPlacement.getTargetedAdUnitIds().length != 0) {
        placementList.add(bannerAdUnitPlacement);
      }

      // Create the placements on the server.
      Placement[] placements =
View Full Code Here

      // Set the ID of the placement to get.
      Long placementId = Long.parseLong("INSERT_PLACEMENT_ID_HERE");

      // Get the placement.
      Placement placement = placementService.getPlacement(placementId);

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

      // Get the PlacementService.
      PlacementServiceInterface placementService =
          user.getService(DfpService.V201302.PLACEMENT_SERVICE);

      // Create local placement object to store skyscraper ad units.
      Placement skyscraperAdUnitPlacement = new Placement();
      skyscraperAdUnitPlacement.setName("Skyscraper AdUnit Placement #"
          + System.currentTimeMillis());
      skyscraperAdUnitPlacement.setDescription(
          "Contains ad units that can hold creatives of size 120x600");
      skyscraperAdUnitPlacement.setTargetedAdUnitIds(new String[] {});

      // Create local placement object to store medium square ad units.
      Placement mediumSquareAdUnitPlacement = new Placement();
      mediumSquareAdUnitPlacement.setName("Medium Square AdUnit Placement #"
          + System.currentTimeMillis());
      mediumSquareAdUnitPlacement.setDescription(
          "Contains ad units that can hold creatives of size 300x250");
      mediumSquareAdUnitPlacement.setTargetedAdUnitIds(new String[] {});

      // Create local placement object to store banner ad units.
      Placement bannerAdUnitPlacement = new Placement();
      bannerAdUnitPlacement.setName("Banner AdUnit Placement #"
          + System.currentTimeMillis());
      bannerAdUnitPlacement.setDescription(
          "Contains ad units that can hold creatives of size 468x60");
      bannerAdUnitPlacement.setTargetedAdUnitIds(new String[] {});

      List<Placement> placementList = new ArrayList<Placement>();

      // Get the first 500 ad units.
      AdUnitPage page = inventoryService.getAdUnitsByStatement(new Statement("LIMIT 500", null));

      // Separate the ad units by size.
      if (page.getResults() != null) {
        for (AdUnit adUnit : page.getResults()) {
          if (adUnit.getParentId() != null && adUnit.getAdUnitSizes() != null) {
            for (AdUnitSize adUnitSize : adUnit.getAdUnitSizes()) {
              Size size = adUnitSize.getSize();
              if (size.getWidth() == 300 && size.getHeight() == 250) {
                Set<String> adUnitIds =
                    new HashSet<String>(Arrays.asList(
                        mediumSquareAdUnitPlacement.getTargetedAdUnitIds()));
                adUnitIds.add(adUnit.getId());
                mediumSquareAdUnitPlacement.setTargetedAdUnitIds(
                    adUnitIds.toArray(new String[] {}));
              } else if (size.getWidth() == 120 && size.getHeight() == 600) {
                Set<String> adUnitIds =
                    new HashSet<String>(Arrays.asList(
                        skyscraperAdUnitPlacement.getTargetedAdUnitIds()));
                adUnitIds.add(adUnit.getId());
                skyscraperAdUnitPlacement.setTargetedAdUnitIds(adUnitIds.toArray(new String[] {}));
              } else if (size.getWidth() == 468 && size.getHeight() == 60) {
                Set<String> adUnitIds =
                    new HashSet<String>(
                       Arrays.asList(bannerAdUnitPlacement.getTargetedAdUnitIds()));
                adUnitIds.add(adUnit.getId());
                bannerAdUnitPlacement.setTargetedAdUnitIds(adUnitIds.toArray(new String[] {}));
              }
            }
          }
        }
      }

      // Only create placements with one or more ad unit.
      if (mediumSquareAdUnitPlacement.getTargetedAdUnitIds().length != 0) {
        placementList.add(mediumSquareAdUnitPlacement);
      }

      if (skyscraperAdUnitPlacement.getTargetedAdUnitIds().length != 0) {
        placementList.add(skyscraperAdUnitPlacement);
      }

      if (bannerAdUnitPlacement.getTargetedAdUnitIds().length != 0) {
        placementList.add(bannerAdUnitPlacement);
      }

      // Create the placements on the server.
      Placement[] placements =
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 contact to update.
      Long contactId = Long.parseLong("INSERT_CONTACT_ID_HERE");

      // Get the contact.
      Contact contact = contactService.getContact(contactId);

      // Update the address of the contact.
      contact.setAddress("123 New Street, New York, NY, 10011");

      // Update the contact on the server.
      Contact[] contacts = contactService.updateContacts(new Contact[] {contact});

      for (Contact updatedContact : contacts) {
View Full Code Here

      // Set the IDs of the companies for the contacts.
      Long advertiserCompanyId = Long.parseLong("INSERT_ADVERTISER_COMPANY_ID_HERE");
      Long agencyCompanyId = Long.parseLong("INSERT_AGENCY_COMPANY_ID_HERE");

      // Create an advertiser contact.
      Contact advertiserContact = new Contact();
      advertiserContact.setName("Mr. Advertiser #" + new Random().nextLong());
      advertiserContact.setEmail("advertiser@advertising.com");
      advertiserContact.setCompanyId(advertiserCompanyId);

      // Create an agency contact.
      Contact agencyContact = new Contact();
      agencyContact.setName("Ms. Agency #" + new Random().nextLong());
      agencyContact.setEmail("agency@agencies.com");
      agencyContact.setCompanyId(agencyCompanyId);

      // Create the contacts on the server.
      Contact[] contacts =
          contactService.createContacts(new Contact[] {advertiserContact, agencyContact});
View Full Code Here

      // Get the ContactService.
      ContactServiceInterface contactService =
          user.getService(DfpService.V201306.CONTACT_SERVICE);

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

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

        // Get contacts by statement.
        page = contactService.getContactsByStatement(filterStatement);

        if (page.getResults() != null) {
          int i = page.getStartIndex();
          for (Contact contact : page.getResults()) {
            System.out.printf(
                "%s) Contact with ID \"%d\" and name \"%s\" was found.\n", i++,
                contact.getId(), contact.getName());
          }
        }

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

      System.out.println("Number of results found: " + page.getTotalResultSetSize());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

TOP

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

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.