Display & Video 360 API, लाइन आइटम बनाने के लिए अन्य तरीके उपलब्ध कराता है. इन तरीकों से, मौजूदा संसाधनों की सेटिंग को नए लाइन आइटम पर लागू किया जा सकता है.
मौजूदा लाइन आइटम डुप्लीकेट करना
duplicate से, एक ही इंसर्शन ऑर्डर के तहत लाइन आइटम की कॉपी बनाई जाती है. इस तरीके से, मौजूदा लाइन आइटम की सेटिंग और टारगेटिंग के साथ एक नया लाइन आइटम बनता है.
लाइन आइटम को डुप्लीकेट करने का तरीका यहां बताया गया है:
Java
// Provide the ID of the parent advertiser. long advertiserId = advertiser-id; // Provide the ID of the existing line item to duplicate. long existingLineItemId = existing-line-item-id; // Provide the display name of the line item to generate. String displayName = display-name; // Provide whether the line item will serve EU political ads. String containsEuPoliticalAds = contains-eu-political-ads; // Create the duplicate line item request structure. DuplicateLineItemRequest duplicateLineItemRequest = new DuplicateLineItemRequest() .setTargetDisplayName(displayName) .setContainsEuPoliticalAds(containsEuPoliticalAds); // Execute the request to generate the line item. DuplicateLineItemResponse response = service .advertisers() .lineItems() .duplicate(advertiserId, existingLineItemId, duplicateLineItemRequest) .execute(); // Display the new line item ID. System.out.printf( "Line Item ID %s was duplicated to create line item ID %s.", existingLineItemId, response.getDuplicateLineItemId());
Python
# Provide the ID of the parent advertiser. advertiser_id = advertiser-id # Provide the ID of the existing line item to duplicate. existing_line_item_id = existing-line-item-id # Provide the display name of the line item to generate. display_name = display-name # Provide whether the line item will serve EU political ads. contains_eu_political_ads = contains-eu-political-ads # Create a line item duplication request. duplication_request = { "targetDisplayName": display_name, "containsEuPoliticalAds": contains_eu_political_ads, } # Build and execute request. duplication_response = ( service.advertisers() .lineItems() .duplicate( advertiserId=advertiser_id, lineItemId=existing_line_item_id, body=duplication_request, ) .execute() ) # Print the ID of the new line item. print( f"Line item ID {existing_line_item_id} was duplicated to create line" " item ID " f'{duplication_response["duplicateLineItemId"]}.' )
PHP
// Provide the ID of the parent advertiser. $advertiserId = advertiser-id; // Provide the ID of the existing line item to duplicate. $existingLineItemId = existing-line-item-id; // Provide the display name of the line item to generate. $displayName = display-name; // Provide whether the line item will serve EU political ads. $containsEuPoliticalAds = contains-eu-political-ads; // Create the duplicate line item request structure. $request = new Google_Service_DisplayVideo_DuplicateLineItemRequest(); $request->setTargetDisplayName($displayName); $request->setContainsEuPoliticalAds($containsEuPoliticalAds); // Call the API, duplicating the line item with the given display name. try { $result = $this->service->advertisers_lineItems->create( $advertiserId, $existingLineItemId, $request ); } catch (\Exception $e) { $this->renderError($e); return; } // Display the new line item ID. printf( '<p>Line Item ID %s was duplicated to create line item ID %s</p>', $existingLineItemId, $result['duplicateLineItemId'] );