// Get DfpUser from "~/dfp.properties".
DfpUser user = new DfpUser();
// Get the PlacementService.
PlacementServiceInterface placementService =
user.getService(DfpService.V201311.PLACEMENT_SERVICE);
// Create a statement to select first 500 placements.
Statement filterStatement = new Statement("LIMIT 500", null);
// Get placements by statement.
PlacementPage page = placementService.getPlacementsByStatement(filterStatement);
if (page.getResults() != null) {
Placement[] placements = page.getResults();
// Update each local placement object by enabling AdSense targeting.
for (Placement placement : placements) {
placement.setTargetingDescription(
(placement.getDescription() == null || placement.getDescription().isEmpty())
? "Generic description" : placement.getDescription());
placement.setTargetingAdLocation("All images on sports pages.");
placement.setTargetingSiteName("http://code.google.com");
placement.setIsAdSenseTargetingEnabled(true);
}
// Update the placements on the server.
placements = placementService.updatePlacements(placements);
// Display results.
if (placements != null) {
for (Placement placement : placements) {
System.out.println("A placement with ID \""