Get all account TextAds via API

31 views
Skip to first unread message

Vadim Galanov

unread,
Aug 10, 2016, 1:42:37 PM8/10/16
to AdWords API Forum
HI all, I'm trying to get All ads from my Adwords account via the API (PHP). I'm using AdGroupAdService:

$adGroupAdService = $user->GetService('AdGroupAdService', self::ADWORDS_VERSION);

$selector = new Selector();
$selector->fields = [
     'Headline',
     'Id',
     'CreativeFinalUrls',
];
$selector->ordering[] = new OrderBy('Headline', 'ASCENDING');
$selector->predicates[] = new Predicate('Status', 'IN', array('ENABLED'));

$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
$result = [];
do
{
    $page = $adGroupAdService->get($selector);
    if (isset($page->entries))
    {
        foreach ($page->entries as $adGroupAd)
        {
            $result[$adGroupAd->ad->id . '#' . $adGroupAd->adGroupId] = [
                'title' => $adGroupAd->ad->headline . "({$adGroupAd->ad->description1} ...)",
                'url' => $adGroupAd->ad->finalUrls[0],
            ];
        }
    }
    else
    {
        print "No text ads were found.\n";
    }
    $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);

And I have only ads from one account's campaign. When trying to find ads from any other campaigns, API returns nothing.
How to get All ads from account from all ads and groups?

Anthony Madrigal

unread,
Aug 10, 2016, 1:56:47 PM8/10/16
to AdWords API Forum
Hi Vadim,

The code you provided should give you all your ads, regardless of campaign since there is no predicate to filter certain campaigns. This should also give you only enabled ads. Are the ads in your other campaigns enabled?

If so, could you please reply privately to author your SOAP request and response so that I can take a further look?

Regards,
Anthony
AdWords API Team

Vadim Galanov

unread,
Aug 10, 2016, 3:28:21 PM8/10/16
to AdWords API Forum
Hi Anthony, thanks for your reply. I just found that my API version (201601) is deprecated so maybe this is the problem. I'll try to migrate to the newest version and check my issue. Thanks!

среда, 10 августа 2016 г., 20:56:47 UTC+3 пользователь Anthony Madrigal написал:
Reply all
Reply to author
Forward
0 new messages