Ramus,

Please send me the response/request XML (without any sensitive info) in 
private.

Also, could I trouble you clarify the sequence of the actions?

Thanks!

Ray

On Tuesday, March 18, 2014 6:35:56 AM UTC-4, Rasmus Larsson wrote:
>
> The problem I'm having is that when I create a targeted placement all 
> other placements in the UI are marked as deleted, however when I send the 
> same request again but this time remove the targeted placement and create 
> an exclusion instead the other placements are back as they were before.
>
> I've pasted the code below, I have another function called 
> "createPlacement" which does almost the exact same thing but creates a 
> biddable criterion instead of a negative criterion.
>
> Any ideas what might be wrong?
>
> $removePlacement = function(AdWordsUser $user, $adGroupId, $url) {
> // Get the AdGroupCriterionService, which loads the required classes.
> $adGroupCriterionService = $user->GetService('AdGroupCriterionService', 
> ADWORDS_VERSION);
>
> // Fetch ID to remove
> $selector = new Selector();
> $selector->fields = array('KeywordText', 'KeywordMatchType', 'Id');
> $selector->predicates[] = new Predicate('AdGroupId', 'IN', 
> array($adGroupId));
> $selector->predicates[] = new Predicate('PlacementUrl', 'IN', array($url));
> $selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
>
> $operations = array();
>
> do {
> // Make the get request.
> $page = $adGroupCriterionService->get($selector);
>
> // Remove results.
> if (isset($page->entries)) {
> foreach ($page->entries as $adGroupCriterion) {
> $adGroupOperation = new AdGroupCriterionOperation();
> $adGroupOperation->operand = $adGroupCriterion;
> $adGroupOperation->operator = "REMOVE";
>
> $operations[] = $adGroupOperation;
> }
> }
>
> // Advance the paging index.
> $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
> } while ($page->totalNumEntries > $selector->paging->startIndex);
>
> // Create exclusion for URL in case it's an automatic placement
> $adGroupNegativeCriterion = new NegativeAdGroupCriterion();
> $adGroupNegativeCriterion->adGroupId = $adGroupId;
> $adGroupNegativeCriterion->criterion = new Placement($url);
>
> $adGroupNegativeOperation = new AdGroupCriterionOperation();
> $adGroupNegativeOperation->operand = $adGroupNegativeCriterion;
> $adGroupNegativeOperation->operator = "ADD";
> $operations[] = $adGroupNegativeOperation;
>
> $adGroupCriterionService->mutate($operations);
> };
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords 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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to