提出 sdfdownloadtasks.create 要求,建立產生結構化資料檔案 (SDF) 的下載工作。
使用要求的下列欄位定義 SDF:
partnerId或advertiserId:互斥欄位,用於定義填入結構化資料檔案的資源的上層資源 (合作夥伴或廣告主)。version:要使用的 SDF 版本,如果與夥伴或廣告主層級的預設設定不同。parentEntityFilter、idFilter或inventorySourceFilter:互斥欄位,用於指派篩選器,指定要納入的檔案類型和資源。
使用這段程式碼片段,為指定廣告主建立廣告訂單和委刊項結構化資料檔案的下載工作,並在提供的廣告活動 ID 範圍內執行:
# Provide the ID of the parent advertiser of the resources to retrieve. advertiser_id = advertiser-id # Provide the Structured Data Files version to download. sdf_version = sdf-version # Provide the IDs of the parent campaigns of the resources to retrieve. campaign_ids = [campaign-id, ...] # Create the request body. body = { 'version': sdf_version, 'advertiserId': advertiser_id, 'parentEntityFilter': { 'fileType': ["FILE_TYPE_INSERTION_ORDER","FILE_TYPE_LINE_ITEM"], 'filterType': "FILTER_TYPE_CAMPAIGN_ID", 'filterIds': campaign_ids } } # Create the operation. operation = service.sdfdownloadtasks().create(body=body).execute() # Print resulting operation name. print(f'Operation {operation["name"]} was created.')