【问题标题】:Block IPs on Google Ads API v2 Beta using Python Library使用 Python 库在 Google Ads API v2 Beta 上阻止 IP
【发布时间】:2019-12-16 15:14:29
【问题描述】:

我正在尝试通过 Google API v2 阻止 IP 列表,但我收到错误“无法定位条件类型”。在字段上:操作,在字段上:创建,在字段上:ip_block。 我的另一个疑问是,我是否需要为列表中的每个 IP 重复创建操作,或者有办法将多个 IP 放在同一个请求上。

client = (google.ads.google_ads.client.GoogleAdsClient.load_from_storage(path="./google-ads.yaml"))
campaign_criterion_operation = client.get_type('CampaignCriterionOperation', version='v2')
campaign_criterion = campaign_criterion_operation.create
campaign_criterion.campaign.value = campaign_service.campaign_path(customer, campaign)
campaign_criterion.ip_block.ip_address.value = "xxx.xxx.xxx.xxx"
campaign_criterion_response = campaign_criterion_service.mutate_campaign_criteria(customer, [campaign_criterion_operation])

for reponse in campaign_criterion_response.results:
    print('Added campaign criterion "%s".' % reponse.resource_name)

【问题讨论】:

    标签: google-ads-api ads-api


    【解决方案1】:

    我认为您收到错误是因为您没有将标准设置为负数。我没有使用 python 库,但我使用的是 PHP 库。

    这就是我的样子;

    $campaign_criterion = new CampaignCriterion([
        'ip_block' => new IpBlockInfo([
            'ip_address' => 'IP_ADDRESS_HERE'
        ]),
        'negative' => true, // setting it to negative
        'campaign' => ResourceNames::forCampaign('XXXXXXXXXX', 'XXXXXXXXXXXX')
    ]);
    

    是的,您必须为每个要阻止的 IP 地址创建一个广告系列标准。

    【讨论】:

    • 嗨詹姆斯,它的。我添加了campaign_criterion.negative.value = True 并像魅力一样工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-24
    • 2011-08-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多