In migrating to v201710, I have some problems in getting Expaned Text Ad.

130 views
Skip to first unread message

Sang Jin Kim

unread,
Nov 20, 2017, 4:43:13 AM11/20/17
to AdWords API Forum

I've been migrating API version from old v201609 to the newest v201710.

I'm PHP developer.


Below is a code that get Expanded Text Ads information.

=============================================================================================

$adGroupAdService = $adWordsServices->get($session, AdGroupAdService::class);

// Create a selector to select all ads for the specified ad group.
$selector = new Selector();
$selector->setFields(['Id', 'Status', 'HeadlinePart1', 'HeadlinePart2', 'Description']);
$selector->setOrdering([new OrderBy('Id', SortOrder::ASCENDING)]);
$selector->setPredicates([
new Predicate('AdGroupId', PredicateOperator::IN, [$AdGroupId]),
new Predicate('AdType', PredicateOperator::IN, [AdType::EXPANDED_TEXT_AD]),
new Predicate('Status', PredicateOperator::IN, [AdGroupAdStatus::ENABLED, AdGroupAdStatus::PAUSED, AdGroupAdStatus::DISABLED])
]);

$selector->setPaging(new Paging(0, self::PAGE_LIMIT));


$totalNumEntries = 0;

do {

  // Retrieve ad group ads one page at a time, continuing to request pages
  // until all ad group ads have been retrieved.
  $page = $adGroupAdService->get($selector);

  // Print out some information for each ad group ad.
  if ($page->getEntries() !== null) {

$totalNumEntries = $page->getTotalNumEntries();

foreach ($page->getEntries() as $adGroupAd) {


$AdId = $adGroupAd->getAd()->getId();

echo "AdId : ".$AdId."\n";


$status = $adGroupAd->getStatus();

echo "status : ".$status."\n"; //ENABLED, PAUSED, DISABLED



//The approvalStatus, trademarks, disapprovalReasons, and trademarkDisapproved fields of AdGroupAd have been removed. Use AdGroupAd.policySummary instead.


$PolicySummary = $adGroupAd->getPolicySummary();

var_dump($PolicySummary);   //return NULL



/*
$approvalStatus = $adGroupAd->getApprovalStatus();
echo "approvalStatus : ".$approvalStatus."\n"; //APPROVED, DISAPPROVED, FAMILY_SAFE, NON_FAMILY_SAFE, PORN, UNCHECKED, UNKNOWN

$disapprovalReasons = $adGroupAd->getDisapprovalReasons();
$disapprovalReasons = $disapprovalReasons[0];
echo "disapprovalReasons : ".$disapprovalReasons."\n"; //Array
*/



$headline1 = $adGroupAd->getAd()->getHeadlinePart1();

echo "headline1 : ".$headline1."\n";

$headline2 = $adGroupAd->getAd()->getHeadlinePart2();

echo "headline2 : ".$headline2."\n";

$description = $adGroupAd->getAd()->getDescription();

echo "description : ".$description."\n";


$path1 = $adGroupAd->getAd()->getPath1();

echo "path1 : ".$path1."\n";

$path2 = $adGroupAd->getAd()->getPath2();

echo "path2 : ".$path2."\n";


  }

  $selector->getPaging()->setStartIndex($selector->getPaging()->getStartIndex() + self::PAGE_LIMIT);


} while ($selector->getPaging()->getStartIndex() < $totalNumEntries);


=============================================================================================



[Problem 1]

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

AdGroupAd.approvalStatus

The approvalStatustrademarksdisapprovalReasons, and trademarkDisapprovedfields of AdGroupAd have been removed. Use AdGroupAd.policySummary instead.

-------------------------------------------------------------------------------------------------------------------------


Before migration to v201710, I successfully retrieved approvalStatus, disapprovalReasons. As described in migration guide, I try to use AdGroupAd.policySummary API, which returns only null value.


                 $PolicySummary = $adGroupAd->getPolicySummary();


                 var_dump($PolicySummary);   //return NULL



How should I write code for combinedApprovalStatus.



https://developers.google.com/adwords/api/docs/reference/v201710/AdGroupAdService.AdGroupAdPolicySummary




[Problem 2]

After migrating from v201609 to v201710, retrieving path1 & path2 of displayurl returns null.

As below code, headline1, headline2, description work well. But only path1 & path2 return null. what's the problem in my code


$headline1 = $adGroupAd->getAd()->getHeadlinePart1();

echo "headline1 : ".$headline1."\n";

$headline2 = $adGroupAd->getAd()->getHeadlinePart2();

echo "headline2 : ".$headline2."\n";

$description = $adGroupAd->getAd()->getDescription();

echo "description : ".$description."\n";

$path1 = $adGroupAd->getAd()->getPath1();

echo "path1 : ".$path1."\n";

$path2 = $adGroupAd->getAd()->getPath2();

echo "path2 : ".$path2."\n";




Thanks, in advance!!


Sreelakshmi Sasidharan (AdWords API Team)

unread,
Nov 20, 2017, 2:22:46 PM11/20/17
to adwor...@googlegroups.com
Hi, 

Please find my response inline : 
  1. How to get policy summary attributes 
    The policySummary(AdGroupAdPolicySummary) will contain the policy information for the specific ad. To get the attributes of the policy summary, you will need to include 'PolicySummary' in the selector. You should be a able to get the attributes of policy summary like review state and the combine approval status as shown below :
  2. $adGroupAd->getPolicySummary()->getReviewState(),
    $adGroupAd->getPolicySummary()->getcombinedApprovalStatus()

    If you are not able to get the value for this, could you enable logging and share the SOAP logs (request and response)?
  3. Path 1 and path 2 are null :
    The attributes of an Ad will vary depending on the type of the Ad. Could you confirm that the Ad for which you get null values for path 1 and path 2 are expanded text ads? If so, could you please share your AdGroupId and the Ad Id so I can take a look?
Please use reply privately to author while sharing the logs. 

Thanks,
Sreelakshmi, AdWords API Team

Sang Jin Kim

unread,
Nov 24, 2017, 2:16:27 PM11/24/17
to AdWords API Forum

Sorry for late reply ^^;


All problems were due to missed selector fields. 

After 'Path1', 'Path2', 'PolicySummary' are included into setFields() like below, the API works well!

$selector->setFields(['Id', 'Status', 'HeadlinePart1', 'HeadlinePart2', 'Description', 'Path1', 'Path2', 'PolicySummary']);


Thanks a lot !!!






2017년 11월 21일 화요일 오전 4시 22분 46초 UTC+9, Sreelakshmi Sasidharan (AdWords API Team) 님의 말:
Reply all
Reply to author
Forward
0 new messages