如何使用 google api 停止提供广告资产(删除资产链接)

问题描述 投票:0回答:1

我需要将非活动的assets链接到特定的ad,即通过API获得与Google广告网络界面相同的结果。遵循链接

的示例

我自己尝试过两种方法

  1. 我想尝试删除资产本身,但我在文档中发现了一个说明,无法使用AssetService删除资产,因为它不支持删除操作
  2. 好吧,我尝试使用 sample 使用 AdGroupAdService 删除广告(使用 python,但这并不重要),但收到一条有关此操作的消息,不适用于类型为 APP_AD 的广告 消息:“无法删除具有此广告类型的广告组广告。”

最后,我发现信息表明,为了停止某个资产,必须删除该资产与广告之间的链接。但没有任何地方有任何例子说明这是什么或如何做到这一点。任何有关此问题的帮助将不胜感激。

python google-ads-api
1个回答
0
投票

假设您已经知道资源名称:

def remove_asset_from_campaign(customer_id, resource_name):
    """Removes asset (e.g. sitelink) identified by resource_name from campaign. 
    """
    campaign_asset_service = client.get_service("CampaignAssetService")
    campaign_asset_operation = client.get_type("CampaignAssetOperation")
    campaign_asset_operation.remove = resource_name

    campaign_asset_response = campaign_asset_service.mutate_campaign_assets(
        customer_id=customer_id, operations=[campaign_asset_operation]
    )
    print(
        "Campaign criterion with resource name "
        f'"{campaign_asset_response.results[0].resource_name}" was '
        "modified."
    )
© www.soinside.com 2019 - 2024. All rights reserved.