0
votes

I've encountered a problem with the Selector class of the ReportDefinitionService. The class doesn't exist. Here is a code from the official google's example:

// Load the service, so that the required classes are available.
$user->LoadService('ReportDefinitionService', 'v201603');
// Optional: Set clientCustomerId to get reports of your child accounts
// $user->SetClientCustomerId('INSERT_CLIENT_CUSTOMER_ID_HERE');

// Create selector.
$selector = new Selector(); //The error happens here. Class 'Selector' isn't found
$selector->fields = array('CampaignId', 'AdGroupId', 'Id', 'Criteria','CriteriaType', 'Impressions', 'Clicks', 'Cost');

There is no Selector definition at the file /vendor/googleads/googleads-php-lib/src/Google/Api/Ads/AdWords/v201603/ReportDefinitionService.php, whereas this class is defined in many other services.

I'm trying to get it to work on Laravel 5.1

The error goes away if I add the directory vendor/googleads/googleads-php-lib/src/Google/Api/Ads/AdWords/Util/v201603 to my classmap:

"autoload": {
 "classmap": [
  ...
  "vendor/googleads/googleads-php-lib/src/Google/Api/Ads/AdWords/Util/v201603"
 ],
 ...

But I'm not sure whether I can do that. Any idea what's going wrong?

1

1 Answers

1
votes

What you did is correct and expected as stated in this section. The manual classmap is needed as there are some classes declared with the same names in each version directory under src/Google/Api/Ads/AdWords/Util.

In the DownloadCriteriaReport example, which I think you've brought some parts of that here, the ReportUtils.php file is included at line 29. In ReportUtils, class Selector is declared when the ReportClasses file is included.

Hope this help.

Thanet, AdWords API Team