PHP Adwords API получает обновленные URL

Я пытаюсь получить обновленные URL-адреса через API AdWords, но все, что я получаю, это NULL. Я использую последнюю версию клиентской библиотеки (v201502)
Вот код, который я использую

    $adGroupAdService = $this->oGAW->GetService('AdGroupAdService', ADWORDS_VERSION);

$selector = new Selector();
$selector->fields = array('AdGroupId');

// Create predicates.
$selector->predicates[] =
new Predicate('AdGroupId', 'IN', array($adGroupId));
$selector->predicates[] =
new Predicate('AdType', 'IN', array('TEXT_AD', 'DYNAMIC_SEARCH_AD'));

// Create paging controls.
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);

$page = $adGroupAdService->get($selector);

И это возвращает

object(TextAd)[107]
public 'headline' => string 'headline'
public 'description1' => string 'description1'
public 'description2' => string 'description2'
public 'id' => string '76813511440' (length=11)
public 'url' => null
public 'displayUrl' => string 'test.nl/test'
public 'finalUrls' => null
public 'finalMobileUrls' => null
public 'finalAppUrls' => null
public 'trackingUrlTemplate' => null
public 'urlCustomParameters' => null
public 'devicePreference' => null
public 'AdType' => string 'TextAd' (length=6)
private '_parameterMap' (Ad) =>
array (size=1)
'Ad.Type' => string 'AdType' (length=6)

Что я делаю неправильно?

Спасибо!

1

Решение

Поле, которое вы ищете, — «CreativeFinalUrls», просто добавьте это к полям вашего селектора, и он вернет массив окончательных URL-адресов в textAd.finalUrls.

$selector->fields = array('AdGroupId', 'CreativeFinalUrls');

увидеть https://developers.google.com/adwords/api/docs/appendix/selectorfields?hl=en#v201506

2

Другие решения

Я нашел обходной путь, теперь я использую ReportDefinitionService, чтобы получить AD_PERFORMANCE_REPORT на сегодня.

Окончательные URL-адреса отображаются в CSV, который он возвращает.

$oAdwords = Utility_Adwords::getInstance($iCredentials);
$user = $oAdwords->getAdwordsUser($iCredentials, $iCustomerId);
// Load the service, so that the required classes are available.
$user->LoadService('ReportDefinitionService', ADWORDS_VERSION_SPEND);

// Create selector.
$selector = new Selector();
$selector->fields = array('CampaignId', 'CampaignName','CampaignStatus', 'AdGroupId', 'Id', 'AdGroupName', 'AdGroupStatus',  'Status', 'AdType', 'DisplayUrl', 'CreativeDestinationUrl', 'CreativeFinalUrls', 'CreativeTrackingUrlTemplate', 'CreativeUrlCustomParameters');

// Filter out removed criteria.
$selector->predicates[] = new Predicate('CampaignId', 'IN', $aCampaigns);
$selector->predicates[] = new Predicate('AdGroupStatus', 'NOT_IN', array('REMOVED'));
$selector->predicates[] = new Predicate('Status', 'NOT_IN', array('DISABLED'));

// Create report definition.
$reportDefinition = new ReportDefinition();
$reportDefinition->selector = $selector;
$reportDefinition->reportName = 'Ad Performance Report #' . uniqid();
$reportDefinition->dateRangeType = 'TODAY';
$reportDefinition->reportType = 'AD_PERFORMANCE_REPORT';
$reportDefinition->downloadFormat = 'CSV';

// Set additional options.
$options = array('version' => ADWORDS_VERSION_SPEND);

ReportUtils::DownloadReport($reportDefinition, $filePath, $user, $options);
1

По вопросам рекламы [email protected]