我尝试将googleleads php libary集成到Symfony 2.8 lts中。 我需要从我的Adwords campain中获取totalConvValue。 我将我的方法放入symfony服务中。该脚本一直工作到 我想生成报告本身。 当我打电话给\ ReportsUtils时说。 对于ReportUtils :: DownloadReport存在多个定义。 我收到一条错误消息: 尝试从全局命名空间加载“ReportUtils”类。 你忘记了“使用”声明吗? 500内部服务器错误 - ClassNotFoundException
$clientId = '';
$clientSecret = '';
$refreshToken = '';
$developerToken = '';
$userAgent = 'k';
$clientCustomerID = '6';
$adwords_version ='';
$adGroupId = '';
$days = '30';
$keyword_id = '';
// Enter parameters required by the code example.
$campaignId = '';
$oauth2Info = [
'client_id' => $clientId,
'client_secret' => $clientSecret,
'refresh_token' => $refreshToken,
];
// See AdWordsUser constructor
$user = new \AdWordsUser();
if (1 == 1) {
$user->SetDeveloperToken($developerToken);
}
$user->SetUserAgent($userAgent);
$user->SetOAuth2Info($oauth2Info);
$user->SetClientCustomerId($clientCustomerID);
$user->SetUserAgent($userAgent);
//$reportDefinitionService = $user->GetService('ReportDefinitionService');
// Load the service, so that the required classes are available.
// $user->LoadService('ReportDefinitionService', $adwords_version);
// Get the service, which loads the required classes.
$user->GetService('AdGroupCriterionService', $adwords_version);
// Create selector.
$selector = new \Selector();
$selector->fields = array('KeywordText', 'Id', 'TotalConvValue');
// Filter out deleted criteria.
//$selector->predicates[] = new Predicate('Status', 'NOT_IN', array('DELETED'));
$selector->predicates[] = new \Predicate('Id', 'IN', array($keyword_id));
$dateRange = new \DateRange();
$str1 = '-1 days';
$str2 = '-1 days';
if($days > 0)
{
$str1 = '-'.$days.' days';
$str2 = '-'.$days.' days';
}
$dateRange->min = date('Ymd', strtotime($str1));
$dateRange->max = date('Ymd', strtotime($str2));
$selector->dateRange = $dateRange;
// Create report definition.
$reportDefinition = $user->GetService('ReportDefinitionService');
// $user->GetService('CampaignService');
$reportDefinition->selector = $selector;
$reportDefinition->reportName = 'Criteria performance report #' . \uniqid();
$reportDefinition->dateRangeType = 'CUSTOM_DATE';
$reportDefinition->reportType = 'KEYWORDS_PERFORMANCE_REPORT';
$reportDefinition->downloadFormat = 'XML';
// Exclude criteria that haven't recieved any impressions over the date range.
$reportDefinition->includeZeroImpressions = FALSE;
// Set additional options.
$options = array('version' => $adwords_version, 'returnMoneyInMicros' => FALSE);
// Create Report
\ReportUtils::DownloadReport($reportDefinition, $filePath, $user, $options);