设置定位条件

定位选项指定的定位选项,以及 订单项服务都用于结合使用 订单项定位条件Video 360 API。本页介绍并提供了示例 查找可用的定位选项时,请将定位选项分配到 并对订单项执行批量操作,以列出和修改已分配 定位选项。

查找可用的定位选项

定位选项使用用户指定的变量、现有的可定位变量, 实体或预先存在的选项来定义所需的目标受众群体。 使用枚举值或定位选项来识别预先存在的选项 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进行定位。每个 有相应的定位选项 ID。

您可通过 定位选项服务。根据 定位类型,则可以通过以下两种方式之一进行检索:

  • 单独检索或详尽列表:检索 大多数定位类型都可以使用 getlist 方法完成。 使用 targetingTypes.targetingOptions.get 检索 由定位类型和定位选项 ID 标识的定位选项。使用 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 方法完成,如下所示: 以及为实体中列出的各个值提供的服务,例如 广告资源来源 否定关键字locations

构建地图注点定位选项 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。这些规范在 展示广告和Video 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');
}