### Install Google API PHP Client Source: https://developers.google.com/display-video/api/guides/getting-started/configure Installs the necessary Google API client libraries for PHP using Composer. ```bash composer require google/apiclient:"^2.18.2" google/apiclient-services:=">=0.396.0" ``` -------------------------------- ### get Source: https://developers.google.com/display-video/api/reference/rest/current/firstPartyAndPartnerAudiences Gets a first party or partner audience. ```APIDOC ## get ### Description Gets a first party or partner audience. ### Method GET ### Endpoint /firstPartyAndPartnerAudiences/{firstPartyAndPartnerAudienceId} ### Parameters #### Path Parameters - **firstPartyAndPartnerAudienceId** (string) - Required - The ID of the audience to retrieve. ``` -------------------------------- ### Update GET Request URL from v1 to v2 Source: https://developers.google.com/display-video/api/v2-migration-guide When migrating to v2, update your GET request URLs to use the new v2 endpoint. This example shows the change for the `advertisers.get` method. ```HTTP GET https://displayvideo.googleapis.com/v1/advertisers/advertiserId ``` ```HTTP GET https://displayvideo.googleapis.com/v2/advertisers/advertiserId ``` -------------------------------- ### List Google Audiences with Query Parameters Source: https://developers.google.com/display-video/api/reference/rest/v4/googleAudiences/list Example of an HTTP GET request to list Google audiences, demonstrating the use of query parameters for pagination, sorting, and filtering. ```HTTP GET https://displayvideo.googleapis.com/v4/googleAudiences?pageSize=100&pageToken="abc"&orderBy="displayName desc"&filter="displayName:Google"&partnerId=12345 ``` -------------------------------- ### create Source: https://developers.google.com/display-video/api/reference/rest/current/partners.channels.sites Creates a site in a channel. ```APIDOC ## create Creates a site in a channel. ``` -------------------------------- ### Update GET request URL from v2 to v3 Source: https://developers.google.com/display-video/api/v3-migration-guide To use v3 instead of v2, update your request URLs to point to the v3 endpoint. This example shows the change for the advertisers.get method. ```HTTP GET https://displayvideo.googleapis.com/v2/advertisers/advertiserId ``` ```HTTP GET https://displayvideo.googleapis.com/v3/advertisers/advertiserId ``` -------------------------------- ### List Insertion Orders with Query Parameters Source: https://developers.google.com/display-video/api/reference/rest/v4/advertisers.insertionOrders/list Demonstrates how to use query parameters to customize the list of insertion orders. This example shows how to set the page size, order by display name in descending order, and filter by entity status. ```HTTP GET https://displayvideo.googleapis.com/v4/advertisers/1234567/insertionOrders?pageSize=50&orderBy=displayName desc&filter=entityStatus="ENTITY_STATUS_ACTIVE" ``` -------------------------------- ### get Source: https://developers.google.com/display-video/api/reference/rest/current/users Gets a user. ```APIDOC ## get ### Description Gets a user. ### Method GET (Assumed based on typical API patterns for retrieval) ### Endpoint /users/{userId} (Assumed structure) ### Parameters #### Path Parameters - **userId** (string) - Required - The ID of the user to retrieve. ### Response #### Success Response (200) - **name** (string) - The name of the user. - **userId** (string) - The unique identifier for the user. - **email** (string) - The email address of the user. - **displayName** (string) - The display name of the user. - **assignedUserRoles** (array) - The roles assigned to the user. - **lastLoginTime** (string) - The time of the user's last login. #### Response Example (Not provided in source) ``` -------------------------------- ### Create Advertiser in Python Source: https://developers.google.com/display-video/api/guides/tasks/run-ad-campaign/create-advertiser This Python snippet demonstrates how to create an advertiser. It requires the partner ID, display name, domain URL, currency code, billing profile ID, and EU political ads flag. ```Python partner_id = partner-id display_name = display-name domain_url = "http://www.google.com" currency_code = "USD" billing_profile_id = billing-profile-id contains_eu_political_ads = contains-eu-political-ads advertiser_obj = { "partnerId": partner_id, "displayName": display_name, "entityStatus": "ENTITY_STATUS_ACTIVE", "generalConfig": {"domainUrl": domain_url, "currencyCode": currency_code}, "adServerConfig": {"thirdPartyOnlyConfig": {}}, "creativeConfig": {}, "billingConfig": {"billingProfileId": billing_profile_id}, "containsEuPoliticalAds": contains_eu_political_ads, } response = service.advertisers().create(body=advertiser_obj).execute() ``` -------------------------------- ### List Inventory Sources with Query Parameters Source: https://developers.google.com/display-video/api/reference/rest/v4/inventorySources/list Demonstrates how to use query parameters for pagination, sorting, and filtering when listing inventory sources. The `filter` parameter supports various criteria like entity status and exchange. ```HTTP GET https://displayvideo.googleapis.com/v4/inventorySources?pageSize=100&pageToken=""&orderBy="displayName desc"&filter="status.entityStatus=\"ENTITY_STATUS_ACTIVE\" AND exchange=\"EXCHANGE_GOOGLE_AD_MANAGER\""&partnerId=12345 ``` -------------------------------- ### get Source: https://developers.google.com/display-video/api/reference/rest/v4/guaranteedOrders Gets a guaranteed order. ```APIDOC ## get ### Description Gets a guaranteed order. ### Method GET ### Endpoint /v4/guaranteedOrders/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the guaranteed order to retrieve. ``` -------------------------------- ### Authenticate using Service Account (Python) Source: https://developers.google.com/display-video/api/guides/concepts/general/service-accounts This Python example shows how to authenticate using a service account. It includes command-line argument parsing for the JSON key file path and an optional email for impersonation, which is useful for domain-wide delegation. ```python """This example demonstrates how to authenticate using a service account. An optional Google account email to impersonate may be specified as follows: authenticate_using_service_account.py -i This optional flag only applies to service accounts which have domain-wide delegation enabled and wish to make API requests on behalf of an account within that domain. Using this flag will not allow you to impersonate a user from a domain you don't own (e.g., gmail.com). """ import argparse import sys from googleapiclient import discovery import httplib2 from oauth2client import client from oauth2client import tools from oauth2client.service_account import ServiceAccountCredentials ``` -------------------------------- ### get Source: https://developers.google.com/display-video/api/reference/rest/current/inventorySources Gets an inventory source. ```APIDOC ## get ### Description Gets an inventory source. ### Method GET ### Endpoint /inventorySources/{inventorySourceId} ### Parameters #### Path Parameters - **inventorySourceId** (string) - Required - The ID of the inventory source to retrieve. ``` -------------------------------- ### Initialize Advertiser and Line Item IDs Source: https://developers.google.com/display-video/api/guides/managing-line-items/targeting Set up the necessary advertiser and line item IDs before retrieving existing targeting information. ```Python # Provide the ID of the parent advertiser. advertiser_id = advertiser-id # Provide the ID of the line item. line_item_id = line-item-id ``` -------------------------------- ### Create Video Creative in Python Source: https://developers.google.com/display-video/api/guides/tasks/assign-creative/create-video This Python script demonstrates how to create a video creative. Provide the advertiser ID, display name, video media ID, and exit event details. The creative is configured as active and hosted. ```python advertiser_id = advertiser-id display_name = display-name video_media_id = video-media-id exit_event_url = exit-event-url exit_event_name = exit-event-name creative_obj = { "displayName": display_name, "entityStatus": "ENTITY_STATUS_ACTIVE", "hostingSource": "HOSTING_SOURCE_HOSTED", "creativeType": "CREATIVE_TYPE_VIDEO", "assets": [ { "asset": {"mediaId": video_media_id}, "role": "ASSET_ROLE_MAIN", } ], "exitEvents": [ { "name": exit_event_name, "type": "EXIT_EVENT_TYPE_DEFAULT", "url": exit_event_url, } ], } creative_response = ( service.advertisers() .creatives() .create(advertiserId=advertiser_id, body=creative_obj) .execute() ) print(f'Creative was created with ID {creative_response["creativeId"]}.') ``` -------------------------------- ### get Source: https://developers.google.com/display-video/api/reference/rest/v4/partners.targetingTypes.assignedTargetingOptions Gets a single targeting option assigned to a partner. ```APIDOC ## get ### Description Gets a single targeting option assigned to a partner. ### Method GET ### Endpoint /v4/partners/{partnerId}/targetingTypes/{targetingType}/assignedTargetingOptions/{assignedTargetingOptionId} ### Parameters #### Path Parameters - **partnerId** (integer) - Required - The ID of the partner. - **targetingType** (string) - Required - The type of targeting option to retrieve. - **assignedTargetingOptionId** (string) - Required - The ID of the assigned targeting option to retrieve. ``` -------------------------------- ### get Source: https://developers.google.com/display-video/api/reference/rest/v4/advertisers.insertionOrders.targetingTypes.assignedTargetingOptions Gets a single targeting option assigned to an insertion order. ```APIDOC ## get ### Description Gets a single targeting option assigned to an insertion order. ### Method GET ### Endpoint /advertisers/{advertiserId}/insertionOrders/{insertionOrderId}/targetingTypes/{targetingType}/{targetingOptionId} ### Parameters #### Path Parameters - **advertiserId** (string) - Required - The ID of the advertiser. - **insertionOrderId** (string) - Required - The ID of the insertion order. - **targetingType** (string) - Required - The type of targeting option to retrieve. - **targetingOptionId** (string) - Required - The ID of the targeting option to retrieve. ### Response #### Success Response (200) - **targetingOption** (object) - The retrieved targeting option. - **targetingOptionId** (string) - The ID of the targeting option. ``` -------------------------------- ### Create a Display Line Item (Java) Source: https://developers.google.com/display-video/api/guides/tasks/run-ad-campaign/create-line-item This Java code demonstrates how to construct and create a display line item with inherited flight and budget, a partner revenue model, and a maximize spend bidding strategy. ```Java // Provide the ID of the parent advertiser. long advertiserId = advertiser-id // Provide the ID of the parent insertion order. long insertionOrderId = insertion-order-id // Provide the display name of the line item. String displayName = display-name // Provide the list of IDs of the creative resources that the line item will // serve. List creativeIds = creative-ids; // Provide whether the line item will serve EU political ads. String containsEuPoliticalAds = contains-eu-political-ads // Create the line item structure. LineItem lineItem = new LineItem () .setInsertionOrderId(insertionOrderId) .setDisplayName(displayName) .setLineItemType("LINE_ITEM_TYPE_DISPLAY_DEFAULT") .setEntityStatus("ENTITY_STATUS_DRAFT") .setCreativeIds(creativeIds) .setContainsEuPoliticalAds(containsEuPoliticalAds); // Create and set the line item flight. LineItemFlight lineItemFlight = new LineItemFlight().setFlightDateType("LINE_ITEM_FLIGHT_DATE_TYPE_INHERITED"); lineItem.setFlight(lineItemFlight); // Create and set the line item budget. LineItemBudget lineItemBudget = new LineItemBudget().setBudgetAllocationType("LINE_ITEM_BUDGET_ALLOCATION_TYPE_UNLIMITED"); lineItem.setBudget(lineItemBudget); // Create and set the pacing setting. Pacing pacing = new Pacing () .setPacingPeriod("PACING_PERIOD_FLIGHT") .setPacingType("PACING_TYPE_ASAP") .setDailyMaxMicros(10_000L); lineItem.setPacing(pacing); // Create and set the frequency cap. FrequencyCap frequencyCap = new FrequencyCap().setTimeUnit("TIME_UNIT_DAYS").setTimeUnitCount(1).setMaxImpressions(10); lineItem.setFrequencyCap(frequencyCap); // Create and set the partner revenue model. PartnerRevenueModel partnerRevenueModel = new PartnerRevenueModel () .setMarkupType("PARTNER_REVENUE_MODEL_MARKUP_TYPE_TOTAL_MEDIA_COST_MARKUP") .setMarkupAmount(100L); lineItem.setPartnerRevenueModel(partnerRevenueModel); // Create and set the bidding strategy. BiddingStrategy biddingStrategy = new BiddingStrategy () .setMaximizeSpendAutoBid( new MaximizeSpendBidStrategy () .setPerformanceGoalType("BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_AV_VIEWED")); lineItem.setBidStrategy(biddingStrategy); // Configure the create request. LineItems.Create request = service.advertisers().lineItems().create(advertiserId, lineItem); // Create the line item. LineItem response = request.execute(); // Display the new line item ID. System.out.printf("Line Item %s was created.", response.getName()); ``` -------------------------------- ### Create Advertiser (PHP) Source: https://developers.google.com/display-video/api/guides/tasks/run-ad-campaign/create-advertiser Creates a new advertiser with specified details including partner ID, display name, ad server configuration, creative configuration, and billing profile. Requires the Google_Service_DisplayVideo class and its related configuration objects. ```php // Provide the ID of the parent partner. $partnerId = $values['partner_id']; // Provide the display name of the advertiser. $displayName = $values['display_name']; // Provide the ID of the billing profile for the advertiser to use. $billingProfileId = $values['billing_profile_id']; // Provide whether or not the advertiser will serve EU political ads. $containsEuPoliticalAds = $values['contains_eu_political_ads']; // Provide the domain URL and currency code of the advertiser. $domainUrl = "http://www.google.com"; $currencyCode = "USD"; // Create the advertiser structure. $advertiser = new Google_Service_DisplayVideo_Advertiser(); $advertiser->setPartnerId($partnerId); $advertiser->setDisplayName($displayName); $advertiser->setEntityStatus('ENTITY_STATUS_ACTIVE'); $advertiser->setContainsEuPoliticalAds($containsEuPoliticalAds); // Create and set the advertiser general configuration. $generalConfig = new Google_Service_DisplayVideo_AdvertiserGeneralConfig(); $generalConfig->setDomainUrl($domainUrl); $generalConfig->setCurrencyCode($currencyCode); $advertiser->setGeneralConfig($generalConfig); // Create and set the ad server configuration structure. $adServerConfig = new Google_Service_DisplayVideo_AdvertiserAdServerConfig(); $adServerConfig->setThirdPartyOnlyConfig(new Google_Service_DisplayVideo_ThirdPartyOnlyConfig()); $advertiser->setAdServerConfig($adServerConfig); // Create and set the creative configuration structure. $advertiser->setCreativeConfig(new Google_Service_DisplayVideo_AdvertiserCreativeConfig()); // Create and set the billing configuration. $billingConfig = new Google_Service_DisplayVideo_AdvertiserBillingConfig(); $billingConfig->setBillingProfileId($billingProfileId); $advertiser->setBillingConfig($billingConfig); // Call the API, creating the advertiser. try { $result = $this->service->advertisers->create($advertiser); } catch (\Exception $e) { $this->renderError($e); return; } // Print the new advertiser. printf('

Advertiser %s was created.

', $result['name']); ``` -------------------------------- ### get Source: https://developers.google.com/display-video/api/reference/rest/current/advertisers.lineItems.targetingTypes.assignedTargetingOptions Gets a single targeting option assigned to a line item. ```APIDOC ## get ### Description Gets a single targeting option assigned to a line item. ### Method GET ### Endpoint `/advertisers/{advertiserId}/lineItems/{lineItemId}/targetingTypes/{targetingType}/assignedTargetingOptions/{assignedTargetingOptionId}` ### Parameters #### Path Parameters - **advertiserId** (string) - Required - The ID of the advertiser. - **lineItemId** (string) - Required - The ID of the line item. - **targetingType** (string) - Required - The type of targeting option to retrieve. - **assignedTargetingOptionId** (string) - Required - The ID of the assigned targeting option to retrieve. ### Response #### Success Response (200) - **assignedTargetingOption** (object) - The retrieved assigned targeting option. ``` -------------------------------- ### create Source: https://developers.google.com/display-video/api/reference/rest/current/users Creates a new user. ```APIDOC ## create ### Description Creates a new user. ### Method POST (Assumed based on typical API patterns for creation) ### Endpoint /users (Assumed structure) ### Parameters #### Request Body - **name** (string) - Required - The name of the user. - **userId** (string) - Required - The unique identifier for the user. - **email** (string) - Required - The email address of the user. - **displayName** (string) - Optional - The display name of the user. - **assignedUserRoles** (array) - Optional - A list of user roles assigned to the user. - **userRole** (string) - Required - The role assigned to the user (e.g., ADMIN, STANDARD). - **entity_id** (string) - Required - The ID of the partner or advertiser the role applies to. ### Response #### Success Response (200) - **name** (string) - The name of the created user. - **userId** (string) - The unique identifier for the created user. - **email** (string) - The email address of the created user. - **displayName** (string) - The display name of the created user. - **assignedUserRoles** (array) - The roles assigned to the user. - **lastLoginTime** (string) - The time of the user's last login. #### Response Example (Not provided in source) ``` -------------------------------- ### Request Body Example for Advertisers.AdGroups.Patch Source: https://developers.google.com/display-video/api/reference/rest/v4/advertisers.adGroups/patch This is an example of the request body for the Advertisers.AdGroups.Patch method, which should contain an instance of AdGroup. ```json { "adGroup": { "advertiserId": "12345", "adGroupId": "67890", "name": "My Ad Group", "campaignId": "112233", "entityStatus": "ENTITY_STATUS_ACTIVE", "inventorySource": "INVENTORY_SOURCE_UNSPECIFIED", "displayName": "My Ad Group Display Name" } } ``` -------------------------------- ### get Source: https://developers.google.com/display-video/api/reference/rest/current/partners.channels Gets a channel for a partner or advertiser. This method retrieves details of a specific channel based on its owner (partner or advertiser). ```APIDOC ## get Gets a channel for a partner or advertiser. ``` -------------------------------- ### Authenticate using Service Account (Java) Source: https://developers.google.com/display-video/api/guides/concepts/general/service-accounts This Java example demonstrates how to create a `Credential` object using a service account JSON file. It shows how to set OAuth scopes and optionally specify an email address for domain-wide delegation. ```java import com.google.api.client.auth.oauth2.Credential; import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; import com.google.api.services.displayvideo.v4.DisplayVideo; import com.google.api.services.displayvideo.v4.DisplayVideoScopes; import com.google.common.base.Strings; import com.google.common.collect.ImmutableSet; import java.io.FileInputStream; /** * This example demonstrates how to authenticate using a service account. */ public class AuthenticateUsingServiceAccount { // Path to a JSON file containing service account credentials for this application. This file can // be downloaded from the Credentials tab on the Google API Console. private static final String PATH_TO_JSON_FILE = "ENTER_PATH_TO_CLIENT_SECRETS_HERE"; /** * An optional Google account email to impersonate. Only applicable to service accounts which have * enabled domain-wide delegation and wish to make API requests on behalf of an account within * their domain. Setting this field will not allow you to impersonate a user from a domain you * don't own (e.g., gmail.com). */ private static final String EMAIL_TO_IMPERSONATE = ""; // The OAuth 2.0 scopes to request. private static final ImmutableSet OAUTH_SCOPES = ImmutableSet.copyOf(DisplayVideoScopes.all()); private static Credential getServiceAccountCredential( String pathToJsonFile, String emailToImpersonate) throws Exception { // Generate a credential object from the specified JSON file. GoogleCredential credential = GoogleCredential.fromStream(new FileInputStream(pathToJsonFile)); // Update the credential object with appropriate scopes and impersonation info (if applicable). if (Strings.isNullOrEmpty(emailToImpersonate)) { credential = credential.createScoped(OAUTH_SCOPES); } else { credential = new GoogleCredential.Builder() .setTransport(credential.getTransport()) .setJsonFactory(credential.getJsonFactory()) .setServiceAccountId(credential.getServiceAccountId()) .setServiceAccountPrivateKey(credential.getServiceAccountPrivateKey()) .setServiceAccountScopes(OAUTH_SCOPES) // Set the email of the user you are impersonating (this can be yourself). .setServiceAccountUser(emailToImpersonate) .build(); } return credential; } public static void main(String[] args) throws Exception { // Build service account credential. Credential credential = getServiceAccountCredential(PATH_TO_JSON_FILE, EMAIL_TO_IMPERSONATE); // Create a DisplayVideo service instance. // // Note: application name below should be replaced with a value that identifies your // application. Suggested format is "MyCompany-ProductName/Version.MinorVersion". DisplayVideo service = new DisplayVideo.Builder(credential.getTransport(), credential.getJsonFactory(), credential) .setApplicationName("displayvideo-java-service-acct-sample") .build(); // Make API requests. } } ``` -------------------------------- ### List Assigned Inventory Sources with Query Parameters Source: https://developers.google.com/display-video/api/reference/rest/current/inventorySourceGroups.assignedInventorySources/list Demonstrates how to use query parameters like `pageSize`, `pageToken`, `orderBy`, and `filter` to refine the list of assigned inventory sources. The `filter` parameter supports filtering by `assignedInventoryId`. ```HTTP GET https://displayvideo.googleapis.com/v4/inventorySourceGroups/{inventorySourceGroupId}/assignedInventorySources?pageSize=100&pageToken=string&orderBy=assignedInventorySourceId%20desc&filter=assignedInventoryId=12345 ``` -------------------------------- ### APIs Explorer Request Body Example Source: https://developers.google.com/display-video/api/reference/rest/v4/advertisers.adAssets/upload This is an example of how to structure the request body in the APIs Explorer for uploading an ad asset. ```JSON { } ``` -------------------------------- ### Create CustomBiddingAlgorithm Resource (Java) Source: https://developers.google.com/display-video/api/guides/tasks/implement-custom-bidding/create-algorithm Use this Java code to create a CustomBiddingAlgorithm resource. You need to provide the advertiser ID, display name, and algorithm type. The algorithm is set to active by default. ```java // Provide the ID of the advertiser that will own the algorithm. long advertiserId = advertiser-id; // Provide the display name of the algorithm. String displayName = display-name; // Provide the type of custom bidding algorithm. String customBiddingAlgorithmType = custom-bidding-algorithm-type; // Create the custom bidding algorithm structure. CustomBiddingAlgorithm algorithm = new CustomBiddingAlgorithm() .setAdvertiserId(advertiserId) .setDisplayName(displayName) .setEntityStatus("ENTITY_STATUS_ACTIVE") .setCustomBiddingAlgorithmType(customBiddingAlgorithmType); // Create the algorithm. CustomBiddingAlgorithm response = service.customBiddingAlgorithms().create(algorithm).execute(); // Display the new custom bidding algorithm ID. System.out.printf( "Custom Bidding Algorithm was created with the ID %s.", response.getCustomBiddingAlgorithmId()); ``` -------------------------------- ### Negative Keyword Request Body Example Source: https://developers.google.com/display-video/api/reference/rest/current/advertisers.negativeKeywordLists.negativeKeywords/create This is an example of the JSON request body required to create a negative keyword. It should contain an instance of a `NegativeKeyword` object. ```json { "text": "example.com" } ``` -------------------------------- ### Create CustomBiddingAlgorithm Resource (Python) Source: https://developers.google.com/display-video/api/guides/tasks/implement-custom-bidding/create-algorithm This Python code demonstrates how to create a CustomBiddingAlgorithm resource. It requires the advertiser ID, display name, and the type of algorithm. The entity status is set to active. ```python # Provide the ID of the advertiser that will own the algorithm. advertiser_id = advertiser-id # Provide the display name of the algorithm. display_name = display-name # Provide the type of custom bidding algorithm. custom_bidding_algo_type = custom-bidding-algorithm-type # Build CustomBiddingAlgorithm object. custom_bidding_algorithm_obj = { "advertiserId": advertiser_id, "displayName": display_name, "entityStatus": "ENTITY_STATUS_ACTIVE", "customBiddingAlgorithmType": custom_bidding_algo_type, } # Build and execute request. algorithm_response = ( service.customBiddingAlgorithms() .create(body=custom_bidding_algorithm_obj) .execute() ) ``` -------------------------------- ### Basic Filter Criterion Example Source: https://developers.google.com/display-video/api/guides/concepts/optimization/filter-lists A single criterion for filtering resources. Ensure values are wrapped in quotes. This example filters for entities with the status 'ENTITY_STATUS_ACTIVE'. ```text entityStatus="ENTITY_STATUS_ACTIVE" ``` -------------------------------- ### Create a Campaign (PHP) Source: https://developers.google.com/display-video/api/guides/tasks/run-ad-campaign/create-campaign This snippet shows how to construct and create a new campaign using the Google_Service_DisplayVideo API client library in PHP. It includes setting essential campaign details like display name, status, goals, flight dates, and frequency caps. ```php // Provide the ID of the parent advertiser. $advertiserId = advertiser-id; // Provide the display name of the campaign. $displayName = display-name; // Provide the year, month, and day of the start date of the campaign flight. $year = start-date-year; $month = start-date-month; $day = start-date-day; // Create the campaign structure. $campaign = new Google_Service_DisplayVideo_Campaign(); $campaign->setDisplayName($displayName); $campaign->setEntityStatus('ENTITY_STATUS_ACTIVE'); // Create and set the campaign goal. $campaignGoal = new Google_Service_DisplayVideo_CampaignGoal(); $campaignGoal->setCampaignGoalType( 'CAMPAIGN_GOAL_TYPE_BRAND_AWARENESS' ); $performanceGoal = new Google_Service_DisplayVideo_PerformanceGoal(); $performanceGoal->setPerformanceGoalType('PERFORMANCE_GOAL_TYPE_CPV'); $performanceGoal->setPerformanceGoalAmountMicros(1000000); $campaignGoal->setPerformanceGoal($performanceGoal); $campaign->setCampaignGoal($campaignGoal); // Create and set the campaign flight. $campaignFlight = new Google_Service_DisplayVideo_CampaignFlight(); $campaignFlight->setPlannedSpendAmountMicros(1000000); $dateRange = new Google_Service_DisplayVideo_DateRange(); $startDate = new Google_Service_DisplayVideo_Date(); $startDate->setYear($year); $startDate->setMonth($month); $startDate->setDay($day); $dateRange->setStartDate($startDate); $campaignFlight->setPlannedDates($dateRange); $campaign->setCampaignFlight($campaignFlight); // Create and set the frequency cap. $frequencyCap = new Google_Service_DisplayVideo_FrequencyCap(); $frequencyCap->setUnlimited(true); $campaign->setFrequencyCap($frequencyCap); // Call the API, creating the campaign under the given advertiser. try { $result = $this->service->advertisers_campaigns->create( $advertiserId, $campaign ); } catch (\Exception $e) { $this->renderError($e); return; } // Print the new campaign. printf('

Campaign %s was created.

', $result['name']); ``` -------------------------------- ### Create Creative Request Body Example Source: https://developers.google.com/display-video/api/reference/rest/v4/advertisers.creatives/create An example of the request body structure for creating a creative. You need to provide the details of the creative within the Creative object. ```json { "add_request_body_parameters": "" } ``` -------------------------------- ### v3.firstAndThirdPartyAudiences.create Source: https://developers.google.com/display-video/api/reference/rest/v3 Creates a FirstAndThirdPartyAudience. ```APIDOC ## POST /v3/firstAndThirdPartyAudiences ### Description Creates a FirstAndThirdPartyAudience. ### Method POST ### Endpoint /v3/firstAndThirdPartyAudiences ``` -------------------------------- ### DayAndTimeAssignedTargetingOptionDetails JSON Structure Source: https://developers.google.com/display-video/api/reference/rest/current/advertisers.adGroups.targetingTypes.assignedTargetingOptions Represents a segment of time defined on a specific day of the week with start and end times. The start hour must be before the end hour. ```json { "dayOfWeek": enum (DayOfWeek), "startHour": integer, "endHour": integer, "timeZoneResolution": enum (TimeZoneResolution) } ``` -------------------------------- ### Create and Authenticate Google Client (PHP) Source: https://developers.google.com/display-video/api/guides/how-tos/authorizing Initializes a Google_Client, sets application name and scopes, and handles authentication by redirecting to an authorization URL or exchanging an authorization code for an access token. ```php $client = new Google_Client(); // Set up the client. $client->setApplicationName('DV360 API PHP Samples'); $client->addScope(oauth-scope); $client->setAccessType('offline'); $client->setAuthConfigFile(path-to-client-secrets-file); // If the code is passed, authenticate. If not, redirect to authentication page. if (isset($_GET['code'])) { $client->authenticate($_GET['code']); } else { $authUrl = $client->createAuthUrl(); header('Location: ' . $authUrl); } // Exchange authorization code for an access token. $accessToken = $client->getAccessToken(); $client->setAccessToken($accessToken); ``` -------------------------------- ### HTTP GET Request to List Combined Audiences Source: https://developers.google.com/display-video/api/reference/rest/v4/combinedAudiences/list This is the basic HTTP GET request to list combined audiences. It can be customized with various query parameters to filter, sort, and paginate the results. ```HTTP GET https://displayvideo.googleapis.com/v4/combinedAudiences ``` -------------------------------- ### v4.advertisers.create Source: https://developers.google.com/display-video/api/reference/rest/current Creates a new advertiser. Use this method to programmatically set up a new advertiser within the Display & Video 360 platform. ```APIDOC ## POST /v4/advertisers ### Description Creates a new advertiser. ### Method POST ### Endpoint /v4/advertisers ``` -------------------------------- ### Configure Custom Bidding Script GET Request Source: https://developers.google.com/display-video/api/guides/tasks/implement-custom-bidding/upload-script Configures a GET request to retrieve details of a specific custom bidding script. This is part of the process to fetch script status or content. ```python # Configure the script GET request. get_request = ( service.customBiddingAlgorithms() .scripts() .get( customBiddingAlgorithmId=algorithm_id, customBiddingScriptId=script_id, advertiserId=advertiser_id, ) ) ``` -------------------------------- ### Create a new user in Java Source: https://developers.google.com/display-video/api/guides/tasks/grant-user-access/create-user Use this snippet to create a new user with Standard access to specified advertisers. Ensure you have the necessary service object and user details. ```Java String emailAddress = user-email-address; String displayName = user-display-name; List advertiserIds = advertiser-ids; List userRoles = new ArrayList<>(); for (Long id : advertiserIds) { userRoles.add(new AssignedUserRole().setAdvertiserId(id).setUserRole("STANDARD")); } User user = new User() .setEmail(emailAddress) .setDisplayName(displayName) .setAssignedUserRoles(userRoles); User response = service.users().create(user).execute(); System.out.printf("User was created with ID %s.", response.getUserId()); ``` -------------------------------- ### Create Ad Group Request Body Example Source: https://developers.google.com/display-video/api/reference/rest/v4/advertisers.adGroups/create An example of the request body structure for creating an ad group. Use the provided fields to define the ad group's properties. ```JSON { "adGroup": { "advertiserId": "12345", "displayName": "My Ad Group", "campaignId": "67890", "adGroupType": "DEMAND_GEN", "entityStatus": "ENTITY_STATUS_ACTIVE" } } ``` -------------------------------- ### create Source: https://developers.google.com/display-video/api/reference/rest/current/inventorySources Creates a new inventory source. ```APIDOC ## create ### Description Creates a new inventory source. ### Method POST ### Endpoint /inventorySources ### Parameters #### Request Body - **inventorySource** (object) - Required - The inventory source to create. See the [InventorySource resource](https://developers.google.com/display-video/api/reference/rest/v1/inventorySources#InventorySource) for details. ``` -------------------------------- ### Example Sorting by AssignedTargetingOption ID (Descending) Source: https://developers.google.com/display-video/api/reference/rest/v4/partners.targetingTypes.assignedTargetingOptions/list This example shows how to sort the list of assigned targeting options in descending order based on their IDs. Append 'desc' to the field name for descending order. ```string assignedTargetingOptionId desc ``` -------------------------------- ### List Line Items with Pagination Source: https://developers.google.com/display-video/api/reference/rest/current/advertisers.lineItems/list This example demonstrates how to retrieve a specific page of line items using the `pageToken` parameter. This is useful for handling large result sets. ```HTTP GET https://displayvideo.googleapis.com/v4/advertisers/{advertiserId}/lineItems?pageToken="yourPageToken" ``` -------------------------------- ### GuaranteedOrder Request Body Example Source: https://developers.google.com/display-video/api/reference/rest/v4/guaranteedOrders/create This is an example of the JSON structure for the GuaranteedOrder object that should be included in the request body when creating a new guaranteed order. It includes essential fields like displayName and sellerInfo. ```JSON { "displayName": "My Guaranteed Order", "sellerInfo": { "தியான": "SELLER_NAME" } } ``` -------------------------------- ### Create a new user in Python Source: https://developers.google.com/display-video/api/guides/tasks/grant-user-access/create-user This Python snippet demonstrates how to create a new user with Standard roles for given advertisers. It constructs the user object and makes the API call. ```Python email_address = user-email-address user_display_name = user-display-name advertiser_ids = advertiser-ids user_roles = [] for id in advertiser_ids: user_roles.append({"advertiserId": id, "userRole": "STANDARD"}) user_obj = { "email": email_address, "displayName": user_display_name, "assignedUserRoles": user_roles, } user_response = service.users().create(body=user_obj).execute() print(f'User was created with ID {user_response["userId"]}.') ``` -------------------------------- ### Update Mask Example Source: https://developers.google.com/display-video/api/reference/rest/v4/advertisers.channels/patch Demonstrates the format for the required `updateMask` query parameter, which specifies the fields to be updated in the Channel resource. This example shows how to update the user's display name and photo. ```string "user.displayName,photo" ```