Kể từ ngày 8 tháng 9 năm 2025, mỗi mục hàng mới sẽ cần phải khai báo xem mục hàng đó có phân phát quảng cáo chính trị ở Liên minh Châu Âu (EU) hay không. Display & Video 360 API và các tệp SDF được tải lên mà không cung cấp thông tin khai báo sẽ không thành công. Hãy xem trang thông báo về những nội dung không dùng nữa để biết thêm thông tin về cách cập nhật quy trình tích hợp để đưa ra nội dung khai báo này.
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Sau khi thao tác của bạn hoàn tất và bạn đã trích xuất tên tài nguyên từ phản hồi thao tác đã hoàn tất, bạn có thể tải tệp zip chứa các SDF đã tạo xuống bằng phương thức media.download.
Sau đây là ví dụ về cách sử dụng thư viện ứng dụng để tải tệp kết quả xuống:
Java
// Extract download file resource name to use in download requestStringdownloadResourceName=operationResponse.getResponse().get("resourceName").toString();// Configure the Media.download requestMedia.DownloaddownloadRequest=service.media().download(downloadResourceName);// Create output stream for downloaded fileFileOutputStreamoutStream=newFileOutputStream(output-file);// Download filedownloadRequest.executeMediaAndDownloadTo(outStream);System.out.printf("File downloaded to %s\n",outputFile);
Python
# Extract download file resource name to use in download requestresourceName=operation["response"]["resourceName"]# Configure the Media.download requestdownloadRequest=service.media().download_media(resourceName=resourceName)# Create output stream for downloaded fileoutStream=io.FileIO(output-file,mode='wb')# Make downloader objectdownloader=googleHttp.MediaIoBaseDownload(outStream,downloadRequest)# Download media file in chunks until finisheddownload_finished=Falsewhiledownload_finishedisFalse:_,download_finished=downloader.next_chunk()print("File downloaded to %s"%output-file)
PHP
// Get client and set defer so it doesn't immediately return.$client = $this->service->getClient();$client->setDefer(true);// Build media download request.$request = $this->service->media->download( $operation->getResponse()['resourceName'], array('alt' => 'media'));// Call the API, getting the generated SDF.$response = $client->execute($request);$responseBody = $response->getBody();// Writes the downloaded file. If the file already exists, it is// overwritten.file_put_contents(output-file, $responseBody);$client->setDefer(false);printf('File saved to: %s\n', output-file);
Sau khi tải tệp xuống và giải nén, bạn sẽ thấy các tệp dữ liệu có cấu trúc đã tạo. Các tệp được tạo sẽ có tên chung xác định loại tệp SDF (ví dụ: SDF-LineItems.csv).
Tệp đã bỏ qua
Nếu không thể đưa dữ liệu cho một tài nguyên được yêu cầu vào tệp dữ liệu có cấu trúc tương ứng, thì tệp zip đã tải xuống có thể bao gồm tệp "Bỏ qua" (ví dụ: SDF-LineItems-Skipped.csv). Tệp này sẽ có cấu trúc hai cột, cột đầu tiên chứa mã nhận dạng của các tài nguyên không thể đưa vào và cột thứ hai chứa lý do loại trừ các tài nguyên đó.
Tài nguyên có thể bị bỏ qua vì nhiều lý do, bao gồm cả việc ở trạng thái không được hỗ trợ hoặc thuộc loại không được hỗ trợ. Tránh việc bỏ qua tài nguyên bằng cách sử dụng phiên bản SDF mới nhất.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\u003cp\u003eAfter a successful operation, download the generated SDFs as a zip file using the \u003ccode\u003emedia.download\u003c/code\u003e method, ensuring the \u003ccode\u003ealt\u003c/code\u003e parameter is set to \u003ccode\u003emedia\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eClient libraries simplify the download process, but if using a direct download URL, append \u003ccode\u003e?alt=media\u003c/code\u003e to ensure proper data format.\u003c/p\u003e\n"],["\u003cp\u003eExtract the download file resource name from the operation response to initiate the download using your preferred client library (Java, Python, or PHP examples provided).\u003c/p\u003e\n"],["\u003cp\u003eDownloaded zip files contain generically named SDF files; a "Skipped" file might be included if certain resources could not be processed, detailing the reasons for exclusion.\u003c/p\u003e\n"],["\u003cp\u003eMinimize skipped resources by utilizing the latest SDF version to ensure compatibility and support for your resource types and states.\u003c/p\u003e\n"]]],["After a successful operation, extract the `resourceName` to download a zip file containing generated SDFs. Use the `media.download` method with `alt=media` to specify the data format. Client libraries automate this process. Download the file by configuring a `Media.Download` request, creating an output stream, and executing the request to download the file into the stream. The zip file contains structured data files like `SDF-LineItems.csv`. A `Skipped.csv` file might be included, listing resources not included and why.\n"],null,["# Download the SDF\n\nOnce your operation has finished successfully and you've extracted the resource\nname from the completed operation response, you are ready to download the zip\nfile containing your generated SDFs using the [`media.download`](/display-video/api/reference/rest/current/media/download)\nmethod.\n| **Note:** You must specify the data format for your download response as `media` through the `alt` parameter. This can be done by appending `?alt=media` to your download url. Client libraries take care of this for you.\n\nHere's an example of how to use a client library to download the resulting file: \n\n### Java\n\n```java\n// Extract download file resource name to use in download request\nString downloadResourceName = operationResponse.getResponse()\n .get(\"resourceName\").toString();\n\n// Configure the Media.download request\nMedia.Download downloadRequest =\n service\n .media()\n .download(downloadResourceName);\n\n// Create output stream for downloaded file\nFileOutputStream outStream =\n new FileOutputStream(output-file);\n\n// Download file\ndownloadRequest.executeMediaAndDownloadTo(outStream);\n\nSystem.out.printf(\"File downloaded to %s\\n\", outputFile);\n```\n\n### Python\n\n```python\n# Extract download file resource name to use in download request\nresourceName = operation[\"response\"][\"resourceName\"]\n\n# Configure the Media.download request\ndownloadRequest = service.media().download_media(resourceName=resourceName)\n\n# Create output stream for downloaded file\noutStream = io.FileIO(output-file, mode='wb')\n\n# Make downloader object\ndownloader = googleHttp.MediaIoBaseDownload(outStream, downloadRequest)\n\n# Download media file in chunks until finished\ndownload_finished = False\nwhile download_finished is False:\n _, download_finished = downloader.next_chunk()\n\nprint(\"File downloaded to %s\" % output-file)\n```\n\n### PHP\n\n```php\n// Get client and set defer so it doesn't immediately return.\n$client = $this-\u003eservice-\u003egetClient();\n$client-\u003esetDefer(true);\n\n// Build media download request.\n$request = $this-\u003eservice-\u003emedia-\u003edownload(\n $operation-\u003egetResponse()['resourceName'],\n array('alt' =\u003e 'media')\n);\n\n// Call the API, getting the generated SDF.\n$response = $client-\u003eexecute($request);\n$responseBody = $response-\u003egetBody();\n\n// Writes the downloaded file. If the file already exists, it is\n// overwritten.\nfile_put_contents(\u003cvar translate=\"no\"\u003eoutput-file\u003c/var\u003e, $responseBody);\n$client-\u003esetDefer(false);\n\nprintf('File saved to: %s\\n', \u003cvar translate=\"no\"\u003eoutput-file\u003c/var\u003e);\n```\n\nOnce your file is downloaded and unzipped, your generated structured data files\nwill be available to you. The generated files will have generic names\nidentifying the SDF file type (example: `SDF-LineItems.csv`).\n\nSkipped files\n-------------\n\nIf data for a requested resource cannot be included in the corresponding\nstructured data file, the zip file downloaded might include a \"Skipped\" file\n(example: `SDF-LineItems-Skipped.csv`). This file will have a two-column\nstructure, the first containing the IDs of the resources that couldn't be\nincluded and the second containing the reason for their exclusion.\n\nResources may be skipped for many reasons, including being in an unsupported\nstate or of an unsupported type. Avoid having resources skipped by using the\nmost recent version of SDF."]]