此小规模测试可让客户测试新的 Display & Video 360 API Beta 版功能,该功能允许客户使用 Display & Video 360 API 上传结构化数据文件 (SDF)。
此小规模测试允许每个已加入的 Google Cloud 项目每天在每个广告客户下最多上传 30 个 SDF。每个文件最多可包含 10,000 个条目。
如需了解如何使用此小规模测试功能,请参阅我们的上传 SDF 指南。
开始使用
开始使用 Display & Video 360 API 后,请按顺序完成以下步骤,以便使用小规模测试功能。
为您的 Google Cloud 项目注册参加 Beta 版计划
只有已申请并获准参与 Beta 版计划的客户才能使用 Beta 版功能。
在尝试使用 Beta 版功能之前,请先与 Google 销售代表确认您的 Google Cloud 项目 ID 是否已加入 Beta 版计划。
生成 API 密钥
除了标准 Display & Video 360 API 凭据之外,您还必须使用 API 密钥。为您的 Google Cloud 项目生成 API 密钥,以便在客户端配置中使用。
配置客户端
使用 Google API Python 客户端库访问这些小规模测试功能。
以下是安装和配置客户端库以向小规模测试功能发出请求的方法:
Python
安装 google-api-python-client
pip install --upgrade google-api-python-client
导入必要的库。
from google_auth_oauthlib.flow import InstalledAppFlow from googleapiclient import discovery
加载客户端密钥文件并生成授权凭据。
# 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()
使用发现服务创建授权服务对象。
api_key = "API_KEY" api_name = "displayvideo" api_url = f"https://{api_name}.googleapis.com" api_version = "v4" api_label = "SDF_UPLOAD_ALPHA" discovery_url = ( f"{api_url}/$discovery/rest?key={api_key}&version={api_version}&labels={api_label}" ) service = discovery.build(api_name, api_version, discoveryServiceUrl=discovery_url, credentials=credentials)
开始上传 SDF
按照我们的功能指南中的说明开始上传结构化数据文件。