TargetingIdeaService, 800 keywords provided, the limit, yet still get an error

410 views
Skip to first unread message

Chloe

unread,
Aug 25, 2016, 6:42:23 PM8/25/16
to AdWords API Forum
I submitted 800 keywords for TargetingIdeaService. The limit is 800. 

It's giving me an error anyways.
$ yii kw/stats 
Warning: [CollectionSizeError.TOO_MANY @ selector.searchParameters[1].queries]
Error: Giving up.

Here is the code.
  function actionStats() {
   
// 800 limit: https://developers.google.com/adwords/api/docs/appendix/limits#targetingidea
    $keywords
= Keyword::find()->orderBy('modified_on')->limit(800)->all();
    $this
->targetingIdeaService('STATS', $keywords);
   
 
}
 
 
function targetingIdeaService($requestType, $keywords) {
    $gaw
= new GoogleAdWords();
    $user
= $gaw->getUser();
   
// Get the service, which loads the required classes.
    $targetingIdeaService
= $user->GetService('TargetingIdeaService');
   
// Create selector.
    $selector
= new TargetingIdeaSelector();
    $selector
->requestType = $requestType;
    $selector
->ideaType = 'KEYWORD';
   
// 'TARGETED_MONTHLY_SEARCHES' returns monthly historical data
    $selector
->requestedAttributeTypes = array('KEYWORD_TEXT', 'SEARCH_VOLUME', 'CATEGORY_PRODUCTS_AND_SERVICES', 'AVERAGE_CPC', 'COMPETITION');
   
   
// Create language search parameter (optional).
   
// The ID can be found in the documentation:
   
//   https://developers.google.com/adwords/api/docs/appendix/languagecodes
   
// Note: As of v201302, only a single language parameter is allowed.
    $languageParameter
= new LanguageSearchParameter();
    $english
= new Language();
    $english
->id = 1000;
    $languageParameter
->languages = array($english);
   
   
// Create related to query search parameter. Keyword goes in here.
    $relatedToQuerySearchParameter
= new RelatedToQuerySearchParameter();
   
   
// Set the network.
    $networkSearchParameter
= new NetworkSearchParameter();
    $networkSetting
= new NetworkSetting();
    $networkSetting
->targetGoogleSearch = true;
    $networkSetting
->targetSearchNetwork = false;
    $networkSetting
->targetContentNetwork = false;
    $networkSetting
->targetPartnerNetwork = false;
    $networkSearchParameter
->networkSetting = $networkSetting;


   
// Set the location parameter
    $location
= new Location(); // USA // https://developers.google.com/adwords/api/docs/appendix/geotargeting
    $location
->id = 2840;
    $locationParameter
= new LocationSearchParameter();
    $locationParameter
->locations = array($location);


   
// $categoryProductsAndServicesSearchParameter = new CategoryProductsAndServicesSearchParameter();
   
   
// Set all the search parameters to the Selector
    $selector
->searchParameters[] = $relatedToQuerySearchParameter;
    $selector
->searchParameters[] = $languageParameter;
    $selector
->searchParameters[] = $networkSearchParameter;
    $selector
->searchParameters[] = $locationParameter;
   
    $relatedToQuerySearchParameter
->queries = array();
    $index
= 0;
   
foreach ($keywords as $keyword) {
      $relatedToQuerySearchParameter
->queries[] = $keyword->keyword;
     
// echo "$index: $keyword->keyword\n"; $index++;
   
}


   
// Set selector paging (required by this service).
    $selector
->paging = new Paging(0, max(AdWordsConstants::RECOMMENDED_PAGE_SIZE, 800));
   
do {
     
// Make the get request.
     
try {
        $retry
= false;
        $page
= $targetingIdeaService->get($selector);
     
} catch (\SoapFault $e) {
       
Yii::error($e->getMessage());
        echo
("Warning: ".$e->getMessage().PHP_EOL);


I'm using v201605, and versions : * 10.0.0 of PHP composer client library.

Chloe

unread,
Aug 25, 2016, 6:45:29 PM8/25/16
to AdWords API Forum
RECOMMENDED_PAGE_SIZE is 500 but I still tried to hardcode 800 but it didn't help.
Message has been deleted

Chloe

unread,
Aug 25, 2016, 6:54:15 PM8/25/16
to AdWords API Forum
Here is the `request_info.log`. This request was for test environment, but it doesn't work in production either.
[Aug 25 2016 18:33:08.000000 - ERROR] effectiveUser=999999999 service=TargetingIdeaService method=get operators={} responseTime=163 requestId=00053aecfb454cc80ac15e28de0d2694 operations=1 units= server=adwords.google.com isFault=true faultMessage=[CollectionSizeError.TOO_MANY @ selector.searchParameters[1].queries]

Chloe

unread,
Aug 25, 2016, 7:03:55 PM8/25/16
to AdWords API Forum
The real limit seems to be 700 (discovered with manual binary search). I think someone made a typo somewhere.

Michael Cloonan (AdWords API Team)

unread,
Aug 26, 2016, 8:15:41 AM8/26/16
to AdWords API Forum
Hello,

Yes, that is correct. The limit is 700. We are already in the process of updating the documentation. I apologize for the inconvenience.

Regards,
Mike, AdWords API Team
Reply all
Reply to author
Forward
0 new messages