À partir du 8 septembre 2025, chaque nouvelle ligne devra indiquer si elle diffusera ou non des annonces à caractère politique dans l'Union européenne (UE). Les importations de fichiers SDF et les appels à l'API Display & Video 360 qui ne fournissent pas de déclarations échoueront. Pour savoir comment mettre à jour votre intégration afin d'effectuer cette déclaration, consultez notre page sur les abandons de compatibilité.
Restez organisé à l'aide des collections Enregistrez et classez les contenus selon vos préférences.
Une fois les identifiants OAuth 2.0 créés et une bibliothèque cliente installée, vous pouvez commencer à utiliser l'API Display & Video 360. Découvrez comment autoriser, configurer votre client et effectuer votre première requête en suivant le guide de démarrage rapide ci-dessous.
Chargez le fichier de secrets client et générez des identifiants d'autorisation.
La première fois que vous effectuez cette étape, vous êtes invité à accepter une invite d'autorisation dans votre navigateur. Avant d'accepter, assurez-vous d'être connecté avec un compte Google ayant accès à Display & Video 360. Votre application sera autorisée à accéder aux données au nom du compte actuellement connecté. Pour en savoir plus sur les autorisations des utilisateurs dans Display & Video 360, consultez notre guide Autoriser les requêtes.
// Read client secrets file.GoogleClientSecretsclientSecrets;try(Readerreader=Files.newBufferedReader(Paths.get(path-to-client-secrets-file),UTF_8)){clientSecrets=GoogleClientSecrets.load(Utils.getDefaultJsonFactory(),reader);}// Generate authorization credentials.// Set up the authorization code flow.GoogleAuthorizationCodeFlowflow=newGoogleAuthorizationCodeFlow.Builder(Utils.getDefaultTransport(),Utils.getDefaultJsonFactory(),clientSecrets,oauth-scopes).build();Credentialcredential=newAuthorizationCodeInstalledApp(flow,newLocalServerReceiver()).authorize("user");
Créez un client API autorisé.
// Create authorized API client.DisplayVideoservice=newDisplayVideo.Builder(credential.getTransport(),credential.getJsonFactory(),credential).setApplicationName("displayvideo-java-installed-app-sample").build();
Effectuez une opération.
// Perform an operation.// Retrieve and print the first ten advertisers under a partner.ListAdvertisersResponseresponse=service.advertisers().list().setPartnerId(partner-id).setPageSize(10).execute();if(response.getAdvertisers().size() > 0){for(inti=0;i < response.getAdvertisers().size();i++){System.out.printf("ID: %s Display Name: %s%n",response.getAdvertisers().get(i).getAdvertiserId(),response.getAdvertisers().get(i).getDisplayName());}}else{System.out.print("No advertisers found.");}
Chargez le fichier de secrets client et générez des identifiants d'autorisation.
La première fois que vous effectuez cette étape, vous êtes invité à accepter une invite d'autorisation dans votre navigateur. Avant d'accepter, assurez-vous d'être connecté avec un compte Google ayant accès à Display & Video 360. Votre application sera autorisée à accéder aux données au nom du compte actuellement connecté. Pour en savoir plus sur les autorisations des utilisateurs dans Display & Video 360, consultez notre guide Autoriser les requêtes.
# Set up a flow object to create the credentials using the# client secrets file and OAuth scopes.credentials=InstalledAppFlow.from_client_secrets_file(path-to-client-secrets-file,oauth-scopes).run_local_server()
Créez un client API autorisé.
# Build the discovery document URL.discovery_url=f'https://displayvideo.googleapis.com/$discovery/rest?version=v4'# Build the API service.service=discovery.build('displayvideo','v4',discoveryServiceUrl=discovery_url,credentials=credentials)
Cet exemple suppose que vous exécutez PHP avec un serveur Web intégré et que vous avez configuré vos identifiants pour rediriger vers la page Web appropriée. Par exemple, ce code, dans un fichier index.php, peut être exécuté à l'aide de la commande suivante et des identifiants configurés pour rediriger vers http://localhost:8000 après l'authentification:
php-Slocalhost:8000-t./
Téléchargez et installez le client PHP de l'API Google.
La méthode privilégiée consiste à utiliser Composer:
Configurez le client, redirigez-le vers l'URL d'authentification si nécessaire et récupérez un jeton d'accès.
La première fois que vous effectuez cette étape, vous êtes invité à accepter une invite d'autorisation dans votre navigateur. Avant d'accepter, assurez-vous d'être connecté avec un compte Google ayant accès à Display & Video 360. Votre application sera autorisée à accéder aux données au nom du compte actuellement connecté. Pour en savoir plus sur les autorisations des utilisateurs dans Display & Video 360, consultez notre guide Autoriser les requêtes.
// 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);
Concevez un client pour le service de l'API Display & Video 360.
$service = new Google_Service_DisplayVideo($client);
Effectuez une opération.
// Configure params for the advertisers.list request.$optParams = array('pageSize' => 10, 'partnerId' => partner-id);// Execute the request.$result = $service->advertisers->listAdvertisers($optParams);// Print the retrieved advertisers.if (!empty($result->getAdvertisers())) { print('<pre>'); foreach ($result->getAdvertisers() as $advertiser) { printf('<p>ID: %s, Display Name: %s</p>', $advertiser->advertiserId, $advertiser->displayName); } print('</pre>');} else { print '<p>No advertisers found.</p>';}
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/25 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/07/25 (UTC)."],[[["\u003cp\u003eThis quickstart guide demonstrates how to get started with the Display & Video 360 API using Java, Python, or PHP.\u003c/p\u003e\n"],["\u003cp\u003eBefore you begin, ensure you have OAuth 2.0 credentials and a compatible client library installed.\u003c/p\u003e\n"],["\u003cp\u003eThe guide provides step-by-step instructions on authorizing your client, configuring it, and executing your first API request.\u003c/p\u003e\n"],["\u003cp\u003eA simple example showcasing the retrieval of advertisers under a partner is included to illustrate the process.\u003c/p\u003e\n"],["\u003cp\u003eYou'll need a Google Account with Display & Video 360 access for authorization.\u003c/p\u003e\n"]]],[],null,["With [OAuth 2.0 credentials created](/display-video/api/guides/getting-started/overview#prerequisites) and a [client library\ninstalled](/display-video/api/guides/getting-started/libraries), you're ready to start using the Display \\& Video 360 API.\nLearn how to authorize, configure your client, and make your first request by\nfollowing the quickstart below. \n\nJava\n\n1. **Import the necessary libraries.**\n\n import static java.nio.charset.StandardCharsets.UTF_8;\n import com.google.api.client.auth.oauth2.Credential;\n import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;\n import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;\n import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow;\n import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets;\n import com.google.api.client.googleapis.util.Utils;\n import com.google.api.services.displayvideo.v4.DisplayVideo;\n import com.google.api.services.displayvideo.v4.DisplayVideo.Advertisers;\n import com.google.api.services.displayvideo.v4.model.Advertiser;\n import com.google.api.services.displayvideo.v4.model.ListAdvertisersResponse;\n import java.io.Reader;\n import java.nio.file.Files;\n import java.nio.file.Paths;\n\n2. **Load the client secrets file and generate authorization credentials.**\n\n\n The first time you perform this step, you are asked to accept an authorization\n prompt in your browser. Before accepting, make sure you're signed in with a\n Google Account that has access to Display \\& Video 360. Your app will be authorized\n to access data on behalf of whichever account is currently signed in. See our\n [Authorize\n Requests](/display-video/api/guides/how-tos/authorizing#user_permissions) guide\n for more details on Display \\& Video 360 user permissions.\n\n // Read client secrets file.\n GoogleClientSecrets clientSecrets;\n try (Reader reader = Files.newBufferedReader(Paths.get(\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003epath\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e-\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003eto\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e-\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003eclient\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e-\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003esecrets\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e-\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003efile\u003c/span\u003e\u003c/var\u003e), UTF_8)) {\n clientSecrets = GoogleClientSecrets.load(Utils.getDefaultJsonFactory(), reader);\n }\n\n // Generate authorization credentials.\n // Set up the authorization code flow.\n GoogleAuthorizationCodeFlow flow =\n new GoogleAuthorizationCodeFlow.Builder(\n Utils.getDefaultTransport(),\n Utils.getDefaultJsonFactory(),\n clientSecrets,\n \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eoauth\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e-\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003escopes\u003c/span\u003e\u003c/var\u003e)\n .build();\n\n Credential credential =\n new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize(\"user\");\n\n3. **Create an authorized API client.**\n\n // Create authorized API client.\n DisplayVideo service =\n new DisplayVideo.Builder(credential.getTransport(), credential.getJsonFactory(), credential)\n .setApplicationName(\"displayvideo-java-installed-app-sample\")\n .build();\n\n4. **Perform an operation.**\n\n // Perform an operation.\n // Retrieve and print the first ten advertisers under a partner.\n ListAdvertisersResponse response =\n service\n .advertisers()\n .list()\n .setPartnerId(\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003epartner\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e-\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003eid\u003c/span\u003e\u003c/var\u003e)\n .setPageSize(10)\n .execute();\n if (response.getAdvertisers().size() \u003e 0) {\n for (int i = 0; i \u003c response.getAdvertisers().size(); i++) {\n System.out.printf(\n \"ID: %s Display Name: %s%n\",\n response.getAdvertisers().get(i).getAdvertiserId(),\n response.getAdvertisers().get(i).getDisplayName());\n }\n } else {\n System.out.print(\"No advertisers found.\");\n }\n\nPython\n\n1. **Import the necessary libraries.**\n\n from google_auth_oauthlib.flow import InstalledAppFlow\n from googleapiclient import discovery\n\n2. **Load the client secrets file and generate authorization credentials.**\n\n\n The first time you perform this step, you are asked to accept an authorization\n prompt in your browser. Before accepting, make sure you're signed in with a\n Google Account that has access to Display \\& Video 360. Your app will be authorized\n to access data on behalf of whichever account is currently signed in. See our\n [Authorize\n Requests](/display-video/api/guides/how-tos/authorizing#user_permissions) guide\n for more details on Display \\& Video 360 user permissions.\n\n # Set up a flow object to create the credentials using the\n # client secrets file and OAuth scopes.\n credentials = InstalledAppFlow.from_client_secrets_file(\n \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003epath\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e-\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003eto\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e-\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003eclient\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e-\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003esecrets\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e-\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003efile\u003c/span\u003e\u003c/var\u003e, \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eoauth\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e-\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003escopes\u003c/span\u003e\u003c/var\u003e).run_local_server()\n\n3. **Create an authorized API client.**\n\n # Build the discovery document URL.\n discovery_url = f'https://displayvideo.googleapis.com/$discovery/rest?version=v4'\n\n # Build the API service.\n service = discovery.build(\n 'displayvideo',\n 'v4',\n discoveryServiceUrl=discovery_url,\n credentials=credentials)\n\n4. **Perform an operation.**\n\n # Build advertisers.list request.\n request = service.advertisers().list(\n partnerId=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003epartner\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e-\u003c/span\u003e\u003cspan class=\"devsite-syntax-nb\"\u003eid\u003c/span\u003e\u003c/var\u003e, pageSize='10')\n\n # Execute request.\n response = request.execute()\n\n # Print response.\n if len(response['advertisers']) \u003e 0:\n for advertiser in response['advertisers']:\n print(f'ID: {advertiser[\"advertiserId\"]} Display Name: {advertiser[\"displayName\"]}')\n else:\n print('No advertisers found.')\n\nPHP\n\n\nThis sample assumes that you are running the PHP with a built-in web server and\nhave configured your credentials to redirect to the relevant web page. For\nexample, this code, in an `index.php` file, can be run using the following\ncommand and credentials configured to redirect to `http://localhost:8000` after\nauthentication: \n\n php -S localhost:8000 -t ./\n\n\u003cbr /\u003e\n\n1. **Download and install the Google API PHP Client.**\n\n The preferred method is using [Composer](//getcomposer.org/): \n\n composer require google/apiclient:^2.18.2 google/apiclient-services:=0.396.0\n\n Once installed, be sure to include the autoloader: \n\n require_once '/path/to/your-project/vendor/autoload.php';\n\n2. **Create a Google_Client object.**\n\n $client = new Google_Client();\n\n3. **Set up the client, redirect to authentication URL if needed, and retrieve an access token.**\n\n\n The first time you perform this step, you are asked to accept an authorization\n prompt in your browser. Before accepting, make sure you're signed in with a\n Google Account that has access to Display \\& Video 360. Your app will be authorized\n to access data on behalf of whichever account is currently signed in. See our\n [Authorize\n Requests](/display-video/api/guides/how-tos/authorizing#user_permissions) guide\n for more details on Display \\& Video 360 user permissions.\n\n // Set up the client.\n $client-\u003esetApplicationName('DV360 API PHP Samples');\n $client-\u003eaddScope(\u003cvar translate=\"no\"\u003eoauth-scope\u003c/var\u003e);\n $client-\u003esetAccessType('offline');\n $client-\u003esetAuthConfigFile(\u003cvar translate=\"no\"\u003epath-to-client-secrets-file\u003c/var\u003e);\n\n // If the code is passed, authenticate. If not, redirect to authentication page.\n if (isset($_GET['code'])) {\n $client-\u003eauthenticate($_GET['code']);\n } else {\n $authUrl = $client-\u003ecreateAuthUrl();\n header('Location: ' . $authUrl);\n }\n\n // Exchange authorization code for an access token.\n $accessToken = $client-\u003egetAccessToken();\n $client-\u003esetAccessToken($accessToken);\n\n4. **Construct a client for the Display \\& Video 360 API service.**\n\n $service = new Google_Service_DisplayVideo($client);\n\n5. **Perform an operation.**\n\n // Configure params for the advertisers.list request.\n $optParams = array('pageSize' =\u003e 10, 'partnerId' =\u003e \u003cvar translate=\"no\"\u003epartner-id\u003c/var\u003e);\n\n // Execute the request.\n $result = $service-\u003eadvertisers-\u003elistAdvertisers($optParams);\n\n // Print the retrieved advertisers.\n if (!empty($result-\u003egetAdvertisers())) {\n print('\u003cpre\u003e');\n foreach ($result-\u003egetAdvertisers() as $advertiser) {\n printf('\u003cp\u003eID: %s, Display Name: %s\u003c/p\u003e', $advertiser-\u003eadvertiserId, $advertiser-\u003edisplayName);\n }\n print('\u003c/pre\u003e');\n } else {\n print '\u003cp\u003eNo advertisers found.\u003c/p\u003e';\n }"]]