Hi there,
I am currently in the process of updating a PHP script I use to manage my
AdWords Campaigns from v201802 to v201809.
I have however run in to slight issue due to changes to the FeedItem Class.
I currently have a function that looks as follows, built for v201802:
function getFeedItems(AdWordsServices $adWordsServices, AdWordsSession
$session, $adCustomizerFeed) {
$page_limit = 500;
// Get the AdCustomizerFeedService, which loads the required classes.
$feedItemService = $adWordsServices->get($session,
FeedItemService::class);
$feedId = $adCustomizerFeed->getFeedId();
$feedItems = array();
// Create selector.
$selector = new Selector();
$selector->setFields(array('FeedItemId','Status','AttributeValues','TargetingAdGroupId'));
// Create predicates.
$selector->setPredicates(array(
new Predicate('Status', 'EQUALS', array('ENABLED')),
new Predicate('FeedId', 'EQUALS', array($feedId))
));
// Create paging controls.
$selector->setPaging(new Paging(0, $page_limit));
$totalNumEntries = 0;
do {
// Make the get request.
$page = $feedItemService->get($selector);
// Display results.
if ($page->getEntries() !== null) {
$totalNumEntries = $page->getTotalNumEntries();
foreach ($page->getEntries() as $feedItem) {
$adGroupId =
(int)$feedItem->getAdGroupTargeting()->getTargetingAdGroupId();
$feedPrice = ($feedItem->getAttributeValues())[0]->getStringValue();
$feedShipping = ($feedItem->getAttributeValues())[1]->getStringValue();
$feedItemId = (int)$feedItem->getFeedItemId();
$feedItems[$adGroupId][0] = $feedItemId;
$feedItems[$adGroupId][1] = $feedPrice;
$feedItems[$adGroupId][2] = $feedShipping;
}
} else {
printLog(sprintf("No feed items were found.\n"));
}
// Advance the paging index.
$selector->getPaging()->setStartIndex(
$selector->getPaging()->getStartIndex() + $page_limit
);
} while ($selector->getPaging()->getStartIndex() < $totalNumEntries);
return $feedItems;
}
The issue is at the following line:
$adGroupId = (int)$feedItem->getAdGroupTargeting()->getTargetingAdGroupId();
As of v201809, the FeedItem class no longer has a 'getAdGroupTargeting'
method. Instead, the method has been moved to the ExtensionFeedItem Class.
I have not been able to find any documentation or sample usage of the
ExtensionFeedItem class and am unsure on how to modify the above function
so that I am still able to retrieve the AdGroup ID from a FeedItem.
Would anyone be willing to show me or point me in the right direction on
how I should modify the above function so that I can still get the AdGroup
ID from the FeedItem?
Thank you all in advance.
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/b9712eed-3136-4c94-85eb-27dbae992e8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.