लाइन आइटम चालू करें

Display & Video 360 API का इस्तेमाल करके बनाए गए सभी लाइन आइटम, शुरू में ड्राफ़्ट स्थिति में बनाए जाते हैं. इस ड्राफ़्ट स्थिति में, लाइन आइटम विज्ञापन नहीं दिखाते, इसलिए आप सेटिंग और टारगेटिंग (विज्ञापन के लिए सही दर्शक चुनना) में बदलाव कर सकते हैं. इस पेज पर बताया गया है कि आपका लाइन आइटम, विज्ञापन दिखाने के लिए तैयार है या नहीं. साथ ही, इसकी स्थिति को 'चालू है' पर कैसे अपडेट करें.

चालू करने से पहले क्या करें

लाइन आइटम जिस तरीके से आपकी विज्ञापन आय को विज्ञापन खरीदने और पेश करने में खर्च होते हैं, उन्हें देखते हुए यह पक्का करना ज़रूरी है कि लाइन आइटम चालू होने पर उम्मीद के मुताबिक विज्ञापन पेश करेगा. लाइन आइटम को चालू करने से पहले, इन बातों का ध्यान रखें:

  • पक्का करें कि फ़्लाइट की सेटिंग सही हैं: लाइन आइटम के flight फ़ील्ड में देखें और पक्का करें कि लाइन आइटम के लिए फ़्लाइट की विंडो सही तरीके से सेट हो. लाइन आइटम की फ़्लाइट विंडो, लाइन आइटम के मुताबिक हो सकती है या उसे पैरंट इंसर्शन ऑर्डर से इनहेरिट किया जा सकता है.
  • पुष्टि करें कि लाइन आइटम को दिखाने में कोई चेतावनी न हो: लाइन आइटम संसाधन को फिर से पाने के लिए advertisers.lineItems.get का इस्तेमाल करें. यह पुष्टि करने के लिए कि लाइन आइटम में ऐसी कोई चेतावनी नहीं है जिसकी वजह से लाइन आइटम को दिखाने में कोई रुकावट न आ रही हो, 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);
    }
}