I submitted 800 keywords for TargetingIdeaService. The limit is 800. 
https://developers.google.com/adwords/api/docs/reference/v201605/TargetingIdeaService#get

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.

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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].
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/9a731468-fcbe-4c2f-b049-a6ba8078bf81%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to