我遇到了ReportDefinitionService的Selector类的问题。这堂课不存在。以下是官方谷歌示例中的代码:
// 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');
文件/vendor/googleads/googleads-php-lib/src/Google/Api/Ads/AdWords/v201603/ReportDefinitionService.php中没有选择器定义,而此类在许多其他服务中定义。
我试图让它在Laravel 5.1上运行
如果我将目录vendor / googleads / googleads-php-lib / src / Google / Api / Ads / AdWords / Util / v201603添加到我的类图中,则错误消失了:
"autoload": {
"classmap": [
...
"vendor/googleads/googleads-php-lib/src/Google/Api/Ads/AdWords/Util/v201603"
],
...
但我不确定自己是否可以这样做。知道出了什么问题吗?
答案 0 :(得分:1)
您所做的是正确的和预期的,如this section中所述。
需要手动类映射,因为在src/Google/Api/Ads/AdWords/Util
下的每个版本目录中都声明了一些具有相同名称的类。
在DownloadCriteriaReport示例中,我认为您已经提到了其中的部分内容,ReportUtils.php文件包含在第29行。 在ReportUtils中,在包含ReportClasses文件时声明类Selector。
希望得到这个帮助。
萨尼特, AdWords API小组