get campaign ip exclusions with api

937 views
Skip to first unread message

Andras Kende

unread,
Apr 16, 2015, 11:01:33 AM4/16/15
to adwor...@googlegroups.com
Hello,

I just started testing Adwords API (php)

So far I can use CampaignCriterionService for IP_BLOCK - ADD / REMOVE to Manage IP exclusions in a Campaign

But not finding any information how to get a list of excluded IP Addresses listed in IP exclusions..

Thanks for any help !

Andras

Nadine Sundquist (AdWords API Team)

unread,
Apr 16, 2015, 12:01:23 PM4/16/15
to adwor...@googlegroups.com
Hi Andras,

In the PHP CampaignCriterionService, there is a get($selector) function that will allow you to filter the list of CampaignCriterion based on fields such as CriteriaType. Check out how CampaignCriterionService selector fields work.

For an example of getting CampaignCriterion by type, we have a PHP example of getting campaign targeting criteria. The type you would need would be IP_BLOCK.

Cheers,
Nadine, AdWords API Team

Andras Kende

unread,
Apr 16, 2015, 8:13:14 PM4/16/15
to adwor...@googlegroups.com
Hi Nadine,

I'm getting the results of IP_BLOCK [id] but the [ipAddress] is empty :(
See my code and results :

<?php
$path = dirname(__FILE__) . '/src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/AdWords/Lib/AdWordsUser.php';
$user = new AdWordsUser();
$user->SetClientCustomerId('111-222-3333');
$campaignId = '123456789';
$campaignCriterionService = $user->GetService('CampaignCriterionService', 'v201502');
$selector = new Selector();
$selector->fields = array('Id', 'CriteriaType');
$selector->predicates[] = new Predicate('CampaignId', 'IN', array($campaignId));
$selector->predicates[] = new Predicate('CriteriaType', 'IN', array('IP_BLOCK'));
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
$page = $campaignCriterionService->get($selector);
print_r($page);
?>


CampaignCriterionPage Object

(

    [entries] => Array

        (

            [0] => NegativeCampaignCriterion Object

                (

                    [campaignId] => 123456789

                    [isNegative] => 1

                    [criterion] => IpBlock Object

                        (

                            [ipAddress] => 

                            [id] => 20471658932

                            [type] => IP_BLOCK

                            [CriterionType] => IpBlock

                            [_parameterMap:Criterion:private] => Array

                                (

                                    [Criterion.Type] => CriterionType

                                )

                        )

                    [bidModifier] => 

                    [forwardCompatibilityMap] => 

                    [CampaignCriterionType] => NegativeCampaignCriterion

                    [_parameterMap:CampaignCriterion:private] => Array

                        (

                            [CampaignCriterion.Type] => CampaignCriterionType

                        )

                )


Thank you,

Andras


Nadine Sundquist (AdWords API Team)

unread,
Apr 17, 2015, 9:39:39 AM4/17/15
to adwor...@googlegroups.com
Hello Andras,

Try getting the IP address information out of KeywordText:

$selector->fields = array('Id', 'CriteriaType', 'KeywordText');

When retrieving information, you need to make sure to specify what you want in the selector.

Best,
Nadine, AdWords API Team

Andras Kende

unread,
Apr 17, 2015, 2:41:42 PM4/17/15
to adwor...@googlegroups.com
Hello Nadine,

It's working now with 'KeywordText'   :) 

                    [criterion] => IpBlock Object
                        (

                            [ipAddress] => 11.11.11.11/32
                            [id] => 38090986511
                            [type] => IP_BLOCK

Thank you !!!

Andras

man...@devmako.sk

unread,
Feb 6, 2017, 4:06:27 PM2/6/17
to AdWords API Forum
Hello Andras
Can you send me FULL php api code how import IPBLOCK to adwords?
I try it 2days but still some error.
Thanks for you answer
Martin
Reply all
Reply to author
Forward
0 new messages