How do I synchronize and download keywords from Google which have been deleted? I have a function which specifically requests Status = REMOVED, and yet it is not returning deleted keywords. The keyword in question also doesn't appear in the web interface in the ad group any more. I considered collecting all the ACTIVE keyword ids, and deleting the rest that are still in my database, but that doesn't work for millions of keywords ("where google_id not in (...)").
public function getKeywords($callback = null) { $user = $this->getUser(); $adGroupCriterionService = $user->GetService('AdGroupCriterionService', ADWORDS_VERSION); $awqlArray = [ "SELECT Id, KeywordText, KeywordMatchType, AdGroupId, Status, CpcBid where CriteriaType = KEYWORD and CampaignId = %s LIMIT %d,%d", "SELECT Id, KeywordText, KeywordMatchType, AdGroupId, Status, CpcBid where CriteriaType = KEYWORD and CampaignId = %s and Status = REMOVED LIMIT %d,%d" ]; $adGroupCriterions = array(); $campaigns = Campaign::find()->all(); # must query by campaign because there are > 100,000 ads. Prevent error: SelectorError.START_INDEX_IS_TOO_HIGH foreach ($campaigns as $campaign) { echo "Getting keywords for campaign $campaign->name\n"; foreach ($awqlArray as $awql) { $offset = 0; do { # must use %s because Google ids are long ints and %d/%u would truncate/corrupt the values $pageQuery = sprintf($awql, $campaign->google_id, $offset, AdWordsConstants::RECOMMENDED_PAGE_SIZE*2); // Make the get request. $page = $adGroupCriterionService->query($pageQuery); // Collect results. if (isset($page->entries)) { foreach ($page->entries as $adGroupCriterion) { // printf("Keyword with text '%s', match type '%s', and ID '%s' was found.\n", // $adGroupCriterion->criterion->text, // $adGroupCriterion->criterion->matchType, // $adGroupCriterion->criterion->id); if ($callback) { // don't save the collection or we will run out of memory $callback($adGroupCriterion); } else { $adGroupCriterions[] = $adGroupCriterion; } } } // Advance the paging offset. $offset += AdWordsConstants::RECOMMENDED_PAGE_SIZE*2; } while ($page->totalNumEntries > $offset); } } return $adGroupCriterions; } -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ 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 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 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/b4272ca0-d56e-4e0c-8a75-bbbd4c51ce55%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.