如何在 dfp api 中创建 CreativeAsset
how to create a CreativeAsset in dfp api
我正在尝试创建一个资产 (CreativeAsset) 以便稍后在模板 Creative 中使用。我在文档中找不到任何创建资产本身的方法,只能提供 base64 字节,但我想在多个地方使用这个资产,所以我宁愿加载一次..有没有办法创建只有一个 CreativeAsset?
这是使用 python 的代码示例:
with open(f, "rb") as html_file:
html_file_data = base64.b64encode(html_file.read())
html_file_data = html_file_data.decode("utf-8")
# USING TEMPLATE
creative1 = {
'xsi_type': 'TemplateCreative',
'name': '',
'advertiserId': '',
'size': {'width': 1, 'height': 1},
'creativeTemplateId': '',
'creativeTemplateVariableValues': [
{
'xsi_type': 'AssetCreativeTemplateVariableValue',
'uniqueName': 'HTMLFile',
'asset': {
'assetByteArray': html_file_data,
'fileName': ''
}
}
# other variables
]
}
# USING CUSTOM
creative2 = {
'xsi_type': 'CustomCreative',
'name': '',
'advertiserId': '',
'size': {'width': 1, 'height': 1},
'destinationUrl': '',
'customCreativeAssets': []
}
creative2['customCreativeAssets'].append({
'xsi_type': 'CustomCreativeAsset',
'macroName': '',
'asset': {
'assetByteArray': html_file_data,
'fileName': ''
}
})
creative_service = dfp_client.GetService('CreativeService', version='v201702')
upload_creative1 = creative_service.createCreatives(creative1)
upload_creative2 = creative_service.createCreatives(creative2)
我希望这能奏效。
这是来自 DFP API 团队的 solution:
A CreativeAsset must be created as a part of a creative. There is no dedicated service to create a CreativeAsset alone. But then, you can use the assetId to copy a CreativeAsset to a new creative. Basically, you can first create a creative, then get the creative asset's assetId and use it to create multiple creatives
我正在尝试创建一个资产 (CreativeAsset) 以便稍后在模板 Creative 中使用。我在文档中找不到任何创建资产本身的方法,只能提供 base64 字节,但我想在多个地方使用这个资产,所以我宁愿加载一次..有没有办法创建只有一个 CreativeAsset?
这是使用 python 的代码示例:
with open(f, "rb") as html_file:
html_file_data = base64.b64encode(html_file.read())
html_file_data = html_file_data.decode("utf-8")
# USING TEMPLATE
creative1 = {
'xsi_type': 'TemplateCreative',
'name': '',
'advertiserId': '',
'size': {'width': 1, 'height': 1},
'creativeTemplateId': '',
'creativeTemplateVariableValues': [
{
'xsi_type': 'AssetCreativeTemplateVariableValue',
'uniqueName': 'HTMLFile',
'asset': {
'assetByteArray': html_file_data,
'fileName': ''
}
}
# other variables
]
}
# USING CUSTOM
creative2 = {
'xsi_type': 'CustomCreative',
'name': '',
'advertiserId': '',
'size': {'width': 1, 'height': 1},
'destinationUrl': '',
'customCreativeAssets': []
}
creative2['customCreativeAssets'].append({
'xsi_type': 'CustomCreativeAsset',
'macroName': '',
'asset': {
'assetByteArray': html_file_data,
'fileName': ''
}
})
creative_service = dfp_client.GetService('CreativeService', version='v201702')
upload_creative1 = creative_service.createCreatives(creative1)
upload_creative2 = creative_service.createCreatives(creative2)
我希望这能奏效。
这是来自 DFP API 团队的 solution:
A CreativeAsset must be created as a part of a creative. There is no dedicated service to create a CreativeAsset alone. But then, you can use the assetId to copy a CreativeAsset to a new creative. Basically, you can first create a creative, then get the creative asset's assetId and use it to create multiple creatives