简体   繁体   中英

Google AdWords API PHP ReportDefinitionService Selector

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM