設定指定目標

指定目標選項指派的指定目標選項,以及 委刊項服務都會結合使用 委刊項指定目標Video 360 API。本頁面提供說明並提供範例 如何找出可用的指定目標選項、替委刊項指派指定目標選項 也可以對委刊項執行大量作業,以便列出及編輯指派的項目 指定目標選項

尋找可用的指定目標選項

指定目標選項可以使用使用者指定的變數、現有的可指定變數 或現有的選項,來定義理想的目標對象。 使用列舉值或指定選項識別現有選項 視指定類型而定可識別的實體是藉由 實體 ID如要找出指定目標選項 ID 和實體 ID,您可以使用 多媒體和Video 360 API。

使用組合列舉值

指派了以下指定類型的指定目標選項時,使用的是 特定列舉類型:

TargetingType 列舉
TARGETING_TYPE_AGE_RANGE AgeRange
TARGETING_TYPE_CONTENT_INSTREAM_POSITION ContentInstreamPosition
TARGETING_TYPE_CONTENT_OUTSTREAM_POSITION ContentOutstreamPosition
TARGETING_TYPE_DEVICE_TYPE DeviceType
TARGETING_TYPE_DIGITAL_CONTENT_LABEL_EXCLUSION ContentRatingTier
TARGETING_TYPE_ENVIRONMENT Environment
TARGETING_TYPE_EXCHANGE Exchange
TARGETING_TYPE_GENDER Gender
TARGETING_TYPE_HOUSEHOLD_INCOME HouseholdIncome
TARGETING_TYPE_NATIVE_CONTENT_POSITION NativeContentPosition
TARGETING_TYPE_OMID Omid
TARGETING_TYPE_PARENTAL_STATUS ParentalStatus
TARGETING_TYPE_SENSITIVE_CATEGORY_EXCLUSION SensitiveCategory
TARGETING_TYPE_VIDEO_PLAYER_SIZE VideoPlayerSize
TARGETING_TYPE_VIEWABILITY Viewability

相關列舉值的字串版本可用來識別現有 這些指定類型的 AssignedTargetingOption 資源, 您可在 assignedTargetingOptionIdAlias 欄位中使用這項屬性你可以 使用這個別名值取代 assignedTargetingOptionId 擷取或刪除指派的指定目標選項。

擷取指定目標選項 ID

採用現有選項的指定類型,會由相應的 指定目標選項 ID

例如,畫面上的位置數量有限 能夠以「TARGETING_TYPE_ON_SCREEN_POSITION」指定類型進行指定。每項 這些位置都有對應的指定選項編號

您可以透過 指定選項服務:根據用途 指定類型則可以透過以下其中一種方式擷取:

  • 擷取個別項目或完整清單:擷取 大多數的指定類型都能使用 getlist 方法完成。 使用 targetingTypes.targetingOptions.get 擷取 透過指定類型和指定選項編號所識別的指定目標選項。使用 targetingTypes.targetingOptions.list 即可列出所有可用 各種指定類型的指定目標選項。
  • 搜尋:指定地區類型的選項 (TARGETING_TYPE_GEO_REGIONTARGETING_TYPE_POITARGETING_TYPE_BUSINESS_CHAIN) 都必須使用 search 方法擷取。 使用 targetingTypes.targetingOptions.search 擷取 符合指定查詢字串的特定類型指定目標選項。
,瞭解如何調查及移除這項存取權。

以下舉例說明如何擷取可能的指定目標 「TARGETING_TYPE_BROWSER」指定類型選項:

Java

// Configure the list request.
TargetingOptions.List request =
   service
       .targetingTypes()
       .targetingOptions()
       .list("TARGETING_TYPE_BROWSER")
       .setAdvertiserId(advertiser-id);

// Create the response and nextPageToken variables.
ListTargetingOptionsResponse response;
String nextPageToken = null;

do {
 // Create and execute the list request.
 response = request.setPageToken(nextPageToken).execute();

 // Check if the response is empty.
 if (response.isEmpty()) {
   System.out.print("List request returned no Targeting Options");
   break;
 }

 // Iterate over retrieved targeting options.
 for (TargetingOption option : response.getTargetingOptions()) {
   System.out.printf(
       "Targeting Option ID: %s, Browser Display Name: '%s'\n",
       option.getTargetingOptionId(), option.getBrowserDetails().getDisplayName());
 }

 // Update the next page token.
 nextPageToken = response.getNextPageToken();
} while (!Strings.isNullOrEmpty(nextPageToken));

Python

# Create the page token variable.
next_page_token = ""

while True:
  # Request the targeting options list.
  response = service.targetingTypes() \
    .targetingOptions().list(
      advertiserId=advertiser-id,
      targetingType="TARGETING_TYPE_BROWSER",
      pageToken=next_page_token
  ).execute()

  # Check if response is empty.
  if not response:
    print("List request returned no Targeting Options")
    break

  # Iterate over retrieved targeting options.
  for option in response['targetingOptions']:
    print("Targeting Option ID: %s, Browser Display Name: %s"
          % (option['targetingOptionId'], option['browserDetails']['displayName']))

  # Break out of loop if there is no next page.
  if 'nextPageToken' not in response:
    break

  # Update the next page token.
  next_page_token = response['nextPageToken']

PHP

// Create the page token variable.
$nextPageToken = null;

do {
    // Build the query parameters object for the request.
    $optParams = array(
        'advertiserId' => advertiser-id,
        'pageToken' => $nextPageToken
    );

    // Call the API, getting the browser targeting options for the
    // identified advertiser.
    $response = $this
        ->service
        ->targetingTypes_targetingOptions
        ->listTargetingTypesTargetingOptions(
            'TARGETING_TYPE_BROWSER',
            $optParams
        );

    // Print the resulting targeting options.
    if (!empty($response->getTargetingOptions())) {
        foreach ($response->getTargetingOptions() as $option) {
            printf(
                'Targeting Option ID: %s, Browser Display Name: %s\n',
                $option['targetingOptionId'],
                $option['browserDetails']['displayName']
            );
        }
    } else {
        print('No targeting options returned\n');
    }

    // Update the next page token.
    $nextPageToken = $response->getNextPageToken();
} while (
    !empty($response->getTargetingOptions())
    && $nextPageToken
);

列出可指定的實體

如要使用現有的可指定實體指定委刊項,您必須 該實體的 ID。可指定的實體,例如管道合併目標對象,以及 廣告空間來源群組,可透過以下方式擷取: 各自的多媒體廣告服務Video 360 API。

每項服務都有專屬的 getlist 方法。使用 get 方法 確認特定廣告客戶是否擁有該實體使用「list」 方法來探索該資源類型的所有實體 因此能用來為某個廣告客戶 委刊項下的任何委刊項

也可以透過 API 管理一部分的可指定實體。這是 是針對相應服務中的 createpatch 方法完成操作,如 以及實體中列出的個別值服務,像是 廣告空間來源 排除關鍵字,以及 地點

建構搜尋點指定目標選項 ID

已命名搜尋點的指定目標選項:TARGETING_TYPE_POI 可以 使用 targetingTypes.targetingOptions.search 擷取。於 此外,您可以建立 TARGETING_TYPE_POI 指定目標選項 ID, 指定特定的經緯度座標。

請按照下列步驟建立搜尋點指定選項 ID:

  1. 擷取經緯度座標 (例如「40.7414691, -74.003387」)
  2. 將座標值四捨五入至小數點後第六位數 (例如:「40.741469, -74.003387」)
  3. 移除座標值中的小數位數 (例如:「40741469, -74003387」)
  4. 將兩個值串連成單一字串,並以半形分號分隔 (例如:「40741469;-74003387」)

建立字串時,產生的字串可當做 targetingOptionId 使用 有 TARGETING_TYPE_POI 個指派的指定目標選項。

建立完成之後,其 targetingOptionIdassignedTargetingOptionId 欄位 指派的指定目標選項資源將會更新,並在結尾加上分號 和英數字元雜湊值

指定指定目標選項

指派給委刊項的指定目標 指定的指定目標選項:如要管理這些實體,請使用 指派指定目標選項服務: 建立指定的指定目標選項後,系統會將這些指定目標詳情套用到 父項委刊項刪除現有的指定指定目標選項後, 。

使用 advertisers.lineItems.targetingTypes.assignedTargetingOptions.create敬上 建立指派的指定目標選項在 所指派指定目標選項資源的 details 欄位, 對應至預定的指定類型

以下舉例說明如何建立指定的指定目標選項 指定類型「TARGETING_TYPE_BROWSER」:

Java

// Create an AssignedTargetingOption object of the
// browser targeting type.
AssignedTargetingOption assignedTargetingOption =
   new AssignedTargetingOption()
       .setBrowserDetails(
           new BrowserAssignedTargetingOptionDetails()
               .setTargetingOptionId(targeting-option-id));

// Configure the create request.
AssignedTargetingOptions.Create request =
   service
       .advertisers()
       .lineItems()
       .targetingTypes()
       .assignedTargetingOptions()
       .create(
           advertiser-id,
           line-item-id,
           "TARGETING_TYPE_BROWSER",
           assignedTargetingOption);

// Send the request.
AssignedTargetingOption response = request.execute();

// Display the new assigned targeting option.
System.out.printf("AssignedTargetingOption %s was created.",
   response.getName());

Python

# Create a assigned targeting option object.
assigned_targeting_option_obj = {
    'browserDetails': {
        'targetingOptionId': targeting-option-id
    }
}

# Create the assigned targeting option.
assigned_targeting_option = service.advertisers().lineItems()\
  .targetingTypes().assignedTargetingOptions().create(
    advertiserId=advertiser-id,
    lineItemId=line-item-id,
    targetingType="TARGETING_TYPE_BROWSER",
    body=assigned_targeting_option_obj
).execute()

# Display the new assigned targeting option.
print("Assigned Targeting Option %s was created."
      % assigned_targeting_option["name"])

PHP

// Create a assigned targeting option object.
$assignedTargetingOption =
    new Google_Service_DisplayVideo_AssignedTargetingOption();

// Create and set browser details.
$details =
    new Google_Service_DisplayVideo_BrowserAssignedTargetingOptionDetails();
$details->setTargetingOptionId(targeting-option-id);
$assignedTargetingOption->setBrowserDetails($details);

// Call the API, creating the browser assigned targeting option for the
// given line item.
$result = $this
    ->service
    ->advertisers_lineItems_targetingTypes_assignedTargetingOptions
    ->create(
        advertiser-id,
        line-item-id,
        'TARGETING_TYPE_BROWSER',
        $assignedTargetingOption
    );

printf(
    'Assigned Targeting Option %s was created.\n',
    $result['name']
);

錯誤

指定目標設定錯誤

有一些複雜的規則 多媒體廣告和指定目標Video 360。系統會在 多媒體和建立指派的指定目標選項時,系統傳回錯誤的影片 360 API。 API 傳回的錯誤會指明違反條件。

錯誤多半是因為指派給委刊項的現有指定目標。使用 advertisers.lineItems.targetingTypes.assignedTargetingOptions.list敬上 擷取已指派給某一行的特定指定類型所有指定目標選項 項目,評估在設有限制的情況下,能否進行所需的指定目標 並使用 advertisers.lineItems.targetingTypes.assignedTargetingOptions.delete。 移除任何不需要的指定目標,然後再次嘗試建立 指派的指定目標選項

YouTube 和合作夥伴指定目標錯誤

指定 YouTube 和合作夥伴廣告活動無法使用 多媒體和Video 360 API 又嘗試這樣做會導致錯誤。

YouTube 和合作夥伴的指定目標包括直接指派給 YouTube 和夥伴委刊項和廣告群組,以及 下列任一指定類型:

  • TARGETING_TYPE_SESSION_POSITION
  • TARGETING_TYPE_YOUTUBE_CHANNEL
  • TARGETING_TYPE_YOUTUBE_VIDEO

並行錯誤

正在嘗試透過 多項並行要求將發生錯誤。

如果需要為單一請求新增或移除多個指定的指定目標選項 委刊項,您應該使用 大量編輯要求。如要更新委刊項的 請將 advertisers.lineItems.patch 連續發出請求和相關指定請求,以確保 直到第一個傳回回應為止。

大量和資源層級指定目標作業

您可以使用大量全資源的指定方式來管理指派的 各種指定類型:

如果想全面掌握委刊項目前的指定目標 為委刊項預設指定目標設定,或需要進行多項變更 同時考量到委刊項指定目標 方法。

大量指定名單

advertisers.lineItems.bulkListAssignedTargetingOptions敬上 可讓您查看指派至一或多個委刊項的所有指定目標 各種不同的指定類型運作方式與任何其他 list 類似 方法。您可以使用 filter 查詢參數來篩選資料 結果:TargetingTypeInheritance

以下示例說明如何列出指派給委刊項的所有指定目標選項 沿用上層夥伴或廣告客戶所沿用的 多個委刊項

Java

// Configure the bulk list request.
LineItems.BulkListAssignedTargetingOptions request =
    service.advertisers().lineItems()
        .bulkListAssignedTargetingOptions(advertiser-id);

// Set Line Items to retrieve targeting for.
request.setLineItemIds(line-item-ids);

// Set filter to only return inherited assigned targeting options.
request.setFilter(
    "inheritance=\"INHERITED_FROM_ADVERTISER\" OR inheritance=\"INHERITED_FROM_PARTNER\"");

// Create the response and nextPageToken variables.
BulkListAssignedTargetingOptionsResponse response;
String nextPageToken = null;

do {
  // Set page token and execute the list request.
  response = request.setPageToken(nextPageToken).execute();

  // Check if the response is empty.
  if (response.isEmpty()) {
    System.out.print("Bulk list request returned no Assigned Targeting Options");
    break;
  }

  // Iterate over retrieved line item assigned targeting option wrapper objects.
  for (LineItemAssignedTargetingOption lineItemAssignedTargetingOption
      : response.getLineItemAssignedTargetingOptions()) {
    System.out.printf(
        "Assigned Targeting Option %s found\n",
        lineItemAssignedTargetingOption.getAssignedTargetingOption().getName());
  }

  // Update the next page token.
  nextPageToken = response.getNextPageToken();
} while (!Strings.isNullOrEmpty(nextPageToken));

Python

# Create the page token variable.
next_page_token = ""

while True:
  # Execute the list request.
  response = service.advertisers().lineItems() \
    .bulkListAssignedTargetingOptions(
      advertiserId=advertiser-id,
      lineItemIds=line-item-ids,
      filter="inheritance=\"INHERITED_FROM_ADVERTISER\" OR "
             "inheritance=\"INHERITED_FROM_PARTNER\"",
      pageToken=next_page_token
  ).execute()

  # Check if response is empty.
  if not response:
    print("Bulk list request returned no Assigned Targeting Options")
    break

  # Iterate over retrieved assigned targeting options.
  for lineItemAssignedTargetingOption in response['lineItemAssignedTargetingOptions']:
    print("Assigned Targeting Option %s found"
          % (lineItemAssignedTargetingOption['assignedTargetingOption']['name']))

  # Break out of loop if there is no next page.
  if 'nextPageToken' not in response:
    break

  # Update the next page token.
  next_page_token = response['nextPageToken']

PHP

// Create the page token variable.
$nextPageToken = null;

do {
    // Build the query parameters object for the request.
    $optParams = array(
        'lineItemIds' => line-item-ids,
        'filter' => "inheritance=\"INHERITED_FROM_ADVERTISER\" OR "
            . "inheritance=\"INHERITED_FROM_PARTNER\"",
        'pageToken' => $nextPageToken
    );

    // Call the API, getting all the assigned targeting options for the
    // identified line item.
    $response = $service
        ->advertisers_lineItems
        ->bulkListAssignedTargetingOptions(
            advertiser-id,
            $optParams
    );

    // Print the returned assigned targeting options.
    if (!empty($response->getLineItemAssignedTargetingOptions())) {
        foreach ($response->getLineItemAssignedTargetingOptions() as $option) {
            printf('Assigned Targeting Option %s found\n', $option->getAssignedTargetingOption()['name']);
        }
    } else {
        print('No targeting options returned\n');
    }

    // Update the next page token.
    $nextPageToken = $response->getNextPageToken();
} while (
    !empty($response->getLineItemAssignedTargetingOptions())
    && $nextPageToken);

大量編輯指定目標

advertisers.lineItems.bulkEditAssignedTargetingOptions敬上 可讓您針對各種指定目標,新增和移除多個指定目標選項 可以選擇的類型

此方法會採用 DeleteAssignedTargetingOptionsRequestsCreateAssignedTargetingOptionsRequests。單一要求 物件可以表示刪除或建立多個指派的指定目標 獲得相同指定類型的選項

萬一您試圖刪除或建立指定的指定目標選項,導致 錯誤,就會放棄該委刊項的大量操作。 要求會傳回成功更新的資料行清單 項目,以及無法成功升級的委刊項清單 「更新」 錯誤

以下範例說明如何大量編輯一或多個指派的指定目標選項 委刊項收到內含刪除和指定目標的指派指定目標選項清單 建立選項:

Java

// Create a bulk edit request.
BulkEditAssignedTargetingOptionsRequest requestContent =
    new BulkEditAssignedTargetingOptionsRequest();

// Set line item IDs in edit request.
requestContent.setLineItemIds(line-item-ids);

// Build delete request list.
ArrayList<DeleteAssignedTargetingOptionsRequest> deleteRequests =
    new ArrayList<DeleteAssignedTargetingOptionsRequest>();

// Add browser assigned targeting option IDs to delete request list.
deleteRequests.add(new DeleteAssignedTargetingOptionsRequest()
    .setTargetingType("TARGETING_TYPE_BROWSER")
    .setAssignedTargetingOptionIds(delete-browser-assigned-targeting-ids));

// Add device make or model assigned targeting option IDs to delete request list.
deleteRequests.add(new DeleteAssignedTargetingOptionsRequest()
    .setTargetingType("TARGETING_TYPE_DEVICE_MAKE_MODEL")
    .setAssignedTargetingOptionIds(
        delete-device-make-model-assigned-targeting-ids));

// Set delete requests in edit request.
requestContent.setDeleteRequests(deleteRequests);

// Build create request list.
ArrayList<CreateAssignedTargetingOptionsRequest> createRequests =
    new ArrayList<CreateAssignedTargetingOptionsRequest>();

// Create browser assigned targeting option create request.
CreateAssignedTargetingOptionsRequest createBrowserTargetingRequest =
    new CreateAssignedTargetingOptionsRequest();
createBrowserTargetingRequest.setTargetingType("TARGETING_TYPE_BROWSER");

// Create and set list of browser assigned targeting options.
ArrayList<AssignedTargetingOption> createBrowserAssignedTargetingOptions =
    new ArrayList<AssignedTargetingOption>();
for (String targetingOptionId : create-browser-assigned-targeting-ids) {
  createBrowserAssignedTargetingOptions.add(new AssignedTargetingOption()
      .setBrowserDetails(
          new BrowserAssignedTargetingOptionDetails()
              .setTargetingOptionId(targetingOptionId)));
}
createBrowserTargetingRequest
    .setAssignedTargetingOptions(createBrowserAssignedTargetingOptions);

// Add browser assigned targeting options to list of create requests.
createRequests.add(createBrowserTargetingRequest);

// Set create requests in edit request.
requestContent.setCreateRequests(createRequests);

// Configure the bulk edit request.
LineItems.BulkEditAssignedTargetingOptions request =
    service.advertisers().lineItems()
        .bulkEditAssignedTargetingOptions(
            advertiser-id,
            requestContent);

// Execute bulk edit request.
BulkEditAssignedTargetingOptionsResponse response = request.execute();

// Check if any line items updated successfully.
if (response.getUpdatedLineItemIds() == null || response.getUpdatedLineItemIds().isEmpty()) {
  System.out.println("No line items were updated successfully.");
} else {
  System.out.printf(
      "Targeting configurations for the following line item IDs were updated: %s.\n",
      Arrays.toString(response.getUpdatedLineItemIds().toArray()));
}

// Check if any line items failed to update.
if (response.getFailedLineItemIds() == null || response.getFailedLineItemIds().isEmpty()) {
  System.out.println("No line items failed to update.");
} else {
  // Print the line items that failed to update.
  System.out.printf(
      "Targeting configurations for the following line item IDs failed to update: %s.\n",
      Arrays.toString(response.getFailedLineItemIds().toArray()));

  // Print errors thrown for failed updates.
  System.out.println("The failed updates were caused by the following errors:");
  for (Status error : response.getErrors()) {
    System.out.printf("Error Code: %s, Message: %s\n", error.getCode(), error.getMessage());
  }
}

Python

# Build assigned targeting option objects to create.
createBrowserAssignedTargetingOptions = []
for targeting_id in create-browser-assigned-targeting-ids:
  createBrowserAssignedTargetingOptions.append(
      {'browserDetails': {'targetingOptionId': targeting_id}}
  )

# Create a bulk edit request.
bulk_edit_line_item_request = {
    'lineItemIds': line-item-ids,
    'deleteRequests': [
        {
            'targetingType': 'TARGETING_TYPE_BROWSER',
            'assignedTargetingOptionIds':
              delete-browser-assigned-targeting-ids
        },
        {
            'targetingType': 'TARGETING_TYPE_DEVICE_MAKE_MODEL',
            'assignedTargetingOptionIds':
              delete-device-make-model-assigned-targeting-ids
        }
    ],
    'createRequests': [
        {
            'targetingType': 'TARGETING_TYPE_BROWSER',
            'assignedTargetingOptions':
              createBrowserAssignedTargetingOptions
        }
    ]
}

# Edit the line item targeting.
response = service.advertisers().lineItems()\
  .bulkEditAssignedTargetingOptions(
    advertiserId=advertiser-id,
    body=bulk_edit_line_item_request
).execute()

# Print successfully updated line items.
if 'updatedLineItemIds' not in response:
  print("No line items were updated successfully.")
else:
  print("Targeting configurations for the following line item IDs were updated: %s"
        % response['updatedLineItemIds'])

# Print line items that failed to update.
if 'failedLineItemIds' not in response:
  print("No line items failed to update.")
else:
  print("Targeting configurations for the following line item IDs failed to update: %s"
        % response['failedLineItemIds'])
  if 'errors' in response:
    print("The failed updates were caused by the following errors:")
    for error in response["errors"]:
      print("Error code: %s, Message: %s" % (error["code"], error["message"]))

PHP

// Create delete request list.
$deleteRequests = array();

// Create and add browser assigned targeting option IDs to delete request list.
$deleteBrowserTargetingRequest =
    new Google_Service_DisplayVideo_DeleteAssignedTargetingOptionsRequest();
$deleteBrowserTargetingRequest->setTargetingType(
    "TARGETING_TYPE_BROWSER"
);
$deleteBrowserTargetingRequest->setAssignedTargetingOptionIds(
    delete-browser-assigned-targeting-ids
);
$deleteRequests[] = $deleteBrowserTargetingRequest;

// Create and add device assigned targeting option IDs to delete request list.
$deleteDeviceTargetingRequest =
    new Google_Service_DisplayVideo_DeleteAssignedTargetingOptionsRequest();
$deleteDeviceTargetingRequest->setTargetingType(
    "TARGETING_TYPE_DEVICE_MAKE_MODEL"
);
$deleteDeviceTargetingRequest->setAssignedTargetingOptionIds(
    delete-device-make-model-assigned-targeting-ids
);
$deleteRequests[] = $deleteDeviceTargetingRequest;

// Create create request list.
$createRequests = array();

// Create and populate list of browser assigned targetion options to create.
$createBrowserAssignedTargetingOptions = array();
foreach (create-browser-assigned-targeting-ids as $optionId) {
    $option = new Google_Service_DisplayVideo_AssignedTargetingOption();
    $details =
        new Google_Service_DisplayVideo_BrowserAssignedTargetingOptionDetails();
    $details->setTargetingOptionId($optionId);

    $option->setBrowserDetails($details);
    $createBrowserAssignedTargetingOptions[] = $option;
}

// Create and add browser assigned targeting option create request to create
// request list.
$createBrowserTargetingRequest =
    new Google_Service_DisplayVideo_CreateAssignedTargetingOptionsRequest();
$createBrowserTargetingRequest->setTargetingType(
    "TARGETING_TYPE_BROWSER"
);
$createBrowserTargetingRequest->setAssignedTargetingOptions(
    $createBrowserAssignedTargetingOptions
);
$createRequests[] = $createBrowserTargetingRequest;

// Create a bulk edit request and assign create and delete request lists.
$body =
    new Google_Service_DisplayVideo_BulkEditAssignedTargetingOptionsRequest();
$body->setLineItemIds(line-item-ids);
$body->setCreateRequests($createRequests);
$body->setDeleteRequests($deleteRequests);

// Call the API, editing the assigned targeting options for the identified
// line item.
$response = $service
    ->advertisers_lineItems
    ->bulkEditAssignedTargetingOptions(
        advertiser-id,
        $body
    );

// Print successfully updated line items.
if (!empty($response->getUpdatedLineItemIds())) {
    printf('Targeting configurations for the following line item IDs were updated:\n');
    foreach ($response->getUpdatedLineItemIds() as $id) {
        printf('%s\n', $id);
    }
} else {
    print('No line items were updated successfully.\n');
}

// Print line items that failed to update.
if (!empty($response->getFailedLineItemIds())) {
    print('Targeting configurations for the following line item IDs failed to update:\n');
    foreach ($response->getFailedLineItemIds() as $id) {
        printf('%s\n', $id);
    }
    print('The failed updates were caused by the following errors:\n');
    foreach ($response->getErrors() as $error) {
        printf('Error Code: %s, Message: %s\n', $error->getCode(), $error->getMessage());
    }
} else {
    print('No line items failed to update.\n');
}