اعتبارًا من 8 سبتمبر 2025، يجب أن يحدّد كل عنصر جديد في الحملة ما إذا كان سيعرض إعلانات سياسية في الاتحاد الأوروبي أم لا. ستتعذّر عمليات تحميل واجهة برمجة التطبيقات "مساحة العرض والفيديو 360" وملفات SDF التي لا تقدّم بيانات الإفصاح. يمكنك الاطّلاع على صفحة الإيقاف النهائي لمزيد من التفاصيل حول كيفية تعديل عملية الدمج لإجراء هذا البيان.
تنظيم صفحاتك في مجموعات يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
بعد إنشاء بيانات اعتماد OAuth 2.0 وتثبيت مكتبة عميل، تكون مستعدًا لبدء استخدام واجهة برمجة التطبيقات Display & Video 360 API. تعرَّف على كيفية تفويض العميل وإعداده وتقديم طلبك الأول من خلال اتّباع الخطوات الواردة في دليل البدء السريع أدناه.
حمِّل ملف أسرار العملاء وأنشئ بيانات اعتماد التفويض.
عند تنفيذ هذه الخطوة لأول مرة، سيُطلب منك قبول طلب تفويض في المتصفّح. قبل القبول، تأكَّد من تسجيل الدخول باستخدام حساب Google لديه إذن الوصول إلى "مساحة العرض والفيديو 360 ". سيتم تفويض تطبيقك بالوصول إلى البيانات نيابةً عن أي حساب تكون مسجِّلاً الدخول إليه حاليًا. اطّلِع على دليل تفويض الطلبات لمزيد من التفاصيل عن أذونات مستخدمي "مساحة العرض والفيديو 360".
// 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");
أنشئ عميل واجهة برمجة تطبيقات مفوَّضًا.
// Create authorized API client.DisplayVideoservice=newDisplayVideo.Builder(credential.getTransport(),credential.getJsonFactory(),credential).setApplicationName("displayvideo-java-installed-app-sample").build();
تنفيذ عملية:
// 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.");}
حمِّل ملف أسرار العملاء وأنشئ بيانات اعتماد التفويض.
عند تنفيذ هذه الخطوة لأول مرة، سيُطلب منك قبول طلب تفويض في المتصفّح. قبل القبول، تأكَّد من تسجيل الدخول باستخدام حساب Google لديه إذن الوصول إلى "مساحة العرض والفيديو 360 ". سيتم تفويض تطبيقك بالوصول إلى البيانات نيابةً عن أي حساب تكون مسجِّلاً الدخول إليه حاليًا. اطّلِع على دليل تفويض الطلبات لمزيد من التفاصيل عن أذونات مستخدمي "مساحة العرض والفيديو 360".
# 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()
أنشئ عميل واجهة برمجة تطبيقات مفوَّضًا.
# 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)
يفترض هذا المثال أنّك تستخدم لغة PHP مع خادم ويب مضمّن و أنّك أعددت بيانات الاعتماد لإعادة التوجيه إلى صفحة الويب ذات الصلة. على سبيل المثال، يمكن تنفيذ هذا الرمز في ملف index.php باستخدام الأمر التالي والبيانات المُعتمَدة التي تم ضبطها لإعادة التوجيه إلى http://localhost:8000 بعد مصادقة:
إعداد العميل وإعادة التوجيه إلى عنوان URL للمصادقة إذا لزم الأمر واسترداد رمز دخول
عند تنفيذ هذه الخطوة لأول مرة، سيُطلب منك قبول طلب تفويض في المتصفّح. قبل القبول، تأكَّد من تسجيل الدخول باستخدام حساب Google لديه إذن الوصول إلى "مساحة العرض والفيديو 360 ". سيتم تفويض تطبيقك بالوصول إلى البيانات نيابةً عن أي حساب تكون مسجِّلاً الدخول إليه حاليًا. اطّلِع على دليل تفويض الطلبات لمزيد من التفاصيل عن أذونات مستخدمي "مساحة العرض والفيديو 360".
// 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);
أنشئ عنصر تحكم لخدمة Display & Video 360 API.
$service = new Google_Service_DisplayVideo($client);
تنفيذ عملية:
// 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>';}
تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\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 }"]]