如何使用DoubleClick DFP API查询 TemplateCreative 类型的广告素材
我可以使用PQL和Python Google Ads API Library通过DFP API查询广告素材。
像这样:
from googleads import dfp client = dfp.DfpClient.LoadFromStorage('./googleads.yaml') creative_service = client.GetService('CreativeService', version='v201502') creative_query = '' creative_statement = dfp.FilterStatement(creative_query, creative_values) while True: response = creative_service.getCreativesByStatement( creative_statement.ToStatement()) if 'results' in response: #do your thing creative_statement.offset += dfp.SUGGESTED_PAGE_LIMIT
这将返回所有广告素材。它像宣传的那样工作!在我的情况下,ImageCreative
,CustomCreative
和TemplateCreative
当我使用查询仅选择ImageCreatives时。它也有效!
像这样:
from googleads import dfp client = dfp.DfpClient.LoadFromStorage('./googleads.yaml') creative_service = client.GetService('CreativeService', version='v201502') creative_values = [{ 'key': 'creativeType', 'value'::{ 'xsi_type': 'TextValue', 'value': 'ImageCreative' } }] creative_query = 'WHERE creativeType = :creativeType' creative_statement = dfp.FilterStatement(creative_query, creative_values) while True: response = creative_service.getCreativesByStatement( creative_statement.ToStatement()) if 'results' in response: #do your thing creative_statement.offset += dfp.SUGGESTED_PAGE_LIMIT
如果我搜索CustomCreative,它也可以。但是我似乎无法查询TemplateCreative
答案 0 :(得分:0)
回答我自己的问题:DFP API似乎不支持此问题:Getting creatives by type TemplateCreative
我采用的解决方案是获取所有广告素材并解析它们。哪个很烂。像这样:
for creative in response['results']:
if "TemplateCreative" in str(creative.__class__):