Hi Peter,

You may use the FeedItemTargetService.get() 
<https://developers.google.com/adwords/api/docs/reference/v201809/FeedItemTargetService#get>
 method 
instead to retrieve the details of your FeedItemAdGroupTarget 
<https://developers.google.com/adwords/api/docs/reference/v201809/FeedItemTargetService.FeedItemAdGroupTarget>.
 
This object includes the adGroupId 
<https://developers.google.com/adwords/api/docs/reference/v201809/FeedItemTargetService.FeedItemAdGroupTarget#adgroupid>
 of 
your target ad group.

Let me know if this is what you are looking for.

Thanks and regards,
Luis
AdWords API Team

On Tuesday, January 15, 2019 at 9:45:40 AM UTC+8, Peter A wrote:
>
> 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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
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 adwords-api+unsubscr...@googlegroups.com.
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/bb8b72f3-7b88-40a5-9929-12bf7cf353db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • ... Peter A
    • ... 'Luis Xander Talag (AdWords API Team)' via AdWords API and Google Ads API Forum
    • ... Peter A

Reply via email to