تفعيل العنصر

يتم في البداية إنشاء جميع العناصر التي تم إنشاؤها باستخدام "مساحة العرض والفيديو 360 API" في حالة مسودة. في حالة المسودة هذه، لا تعرض البنود أي إعلانات، لذا يمكنك ضبط الإعدادات والاستهداف بدون أن تؤثر هذه التغييرات في أي عرض إعلان حالي. توضّح هذه الصفحة الخطوات التي يجب اتّخاذها للتأكّد من أنّ عنصرك جاهز لعرض الإعلانات، وكيفية تعديل حالته إلى "نشط".

الإجراءات التي يجب اتّخاذها قبل التفعيل

بما أنّ العناصر هي الطريقة التي يتم بها إنفاق أرباح إعلاناتك من خلال شراء الإعلانات وعرضها، من المهم التأكّد من أنّ العنصر سيعرِض الإعلانات على النحو المنشود عند تفعيله. وفي ما يلي بعض الأمور التي يجب مراعاتها قبل تنشيط البند:

  • التأكد من صحة إعدادات رحلة الطيران: راجِع حقل flight للعنصر للتأكد من ضبط فترة الرحلة الجوية للعنصر بشكل صحيح. قد تكون فترة عرض معلومات أحد العناصر مخصّصة للعنصر أو قد تكون مكتسَبة من طلب الإدراج الرئيسي.
  • التأكّد من عدم وجود تحذيرات تحظر عرض العنصر: استخدِم advertisers.lineItems.get لاسترداد مورد عنصر وتحقَّق من الحقل warningMessages للتأكّد من أنّ العنصر لا يتضمّن أي تحذيرات قد تعيق عرض العنصر. يشير تعداد LineItemWarningMessage إلى تأثير كل تحذير.
  • التأكد من أن جميع موارد العناصر الرئيسية نشطة أيضًا: لن يبدأ العنصر النشط في عرض الإعلانات إذا لم يكن المعلن الرئيسي أو الحملة أو طلب الإدراج نشطًا. يمكنك استرداد هذه الموارد باستخدام طرق GET في خدمات المعلنون والحملات وطلبات الإدراج.

تفعيل أحد العناصر

يمكنك تفعيل عنصر من خلال تعديل الحقل entityStatus إلى ENTITY_STATUS_ACTIVE. يمكنك تعديل هذا الحقل لعنصر فردي باستخدام طريقة advertisers.lineItems.patch ولبنود متعددة ضمن معلن معيّن باستخدام advertisers.lineItems.bulkUpdate.

في ما يلي مثال على كيفية استخدام bulkUpdate لتفعيل عناصر متعددة:

Java

// Create the line item structure.
LineItem targetLineItem = new LineItem();
targetLineItem.setEntityStatus("ENTITY_STATUS_ACTIVE");

// Create the bulk update request body.
BulkUpdateLineItemsRequest requestBody = new BulkUpdateLineItemsRequest();
requestBody.setLineItemIds(line-item-ids);
requestBody.setTargetLineItem(targetLineItem);
requestBody.setUpdateMask("entityStatus");

// Configure the bulk update request.
LineItems.BulkUpdate request = service.advertisers().lineItems()
    .bulkUpdate(advertiser-id, requestBody);

// Update the line items.
BulkUpdateLineItemsResponse response = request.execute();

// Display the line items that were updated, failed, and skipped.
if (response.getUpdatedLineItemIds() != null) {
  System.out.printf(
      "The following line item IDs were successfully updated: %s.\n",
      Arrays.toString(response.getUpdatedLineItemIds().toArray()));
}
if (response.getFailedLineItemIds() != null) {
  System.out.printf("The following line item IDs failed to update: %s.\n",
      Arrays.toString(response.getFailedLineItemIds().toArray()));
  if (response.getErrors() != null) {
    System.out.printf(
        "The failed updates were caused by the following errors: %s.\n",
        Arrays.toString(response.getErrors().toArray()));
  }
}
if (response.getSkippedLineItemIds() != null) {
  System.out.printf(
      "The following line items IDs were skipped in the update: %s.\n",
      Arrays.toString(response.getSkippedLineItemIds().toArray()));
}

Python

# Create a line item object with only updated entity status.
line_item_obj = {
    'entityStatus': 'ENTITY_STATUS_ACTIVE'
}

# Build the bulk update request.
bulk_update_request = {
    'lineItemIds': line-item-ids,
    'targetLineItem': line_item_obj,
    'updateMask': "entityStatus"
}

# Update the line items.
response = service.advertisers().lineItems().bulkUpdate(
    advertiserId=advertiser-id,
    body=bulk_update_request
).execute()

# Display the line items that were updated, failed, and skipped.
if 'updatedLineItemIds' in response:
  print("The following line item IDs were updated: %s"
        % response['updatedLineItemIds'])
if 'failedLineItemIds' in response:
  print("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"]))
if 'skippedLineItemIds' in response:
  print("The following line items IDs were skipped in the update:: %s"
        % response['skippedLineItemIds'])

PHP

// Create request body.
$body = new Google_Service_DisplayVideo_BulkUpdateLineItemsRequest();
$body->setLineItemIds(line-item-ids);

// Create target line item with updated fields.
$lineItem = new Google_Service_DisplayVideo_LineItem();
$lineItem->setEntityStatus('ENTITY_STATUS_ACTIVE');
$body->setTargetLineItem($lineItem);

// Set update mask in request body.
$body->setUpdateMask("entityStatus");

// Call the API, updating the entity status for the identified line item.
$response = $service->advertisers_lineItems->bulkUpdate(
    advertiser-id,
    $body
);

// Display the line items that were updated, failed, and skipped.
if (!empty($response->getUpdatedLineItemIds())) {
    printf('The following line item IDs were updated:\n');
    foreach ($response->getUpdatedLineItemIds() as $id) {
        printf('%s\n', $id);
    }
}
if (!empty($response->getFailedLineItemIds())) {
    print('The following line item IDs failed to update:\n');
    foreach ($response->getFailedLineItemIds() as $id) {
        printf('%s\n', $id);
    }
    if (!empty($response->getErrors())) {
        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()
            );
        }
    }
}
if (!empty($response->getSkippedLineItemIds())) {
    print('The following line item IDs were skipped in the update:\n');
    foreach ($response->getSkippedLineItemIds() as $id) {
        printf('%s\n', $id);
    }
}