function test(AdWordsUser $user) {
// Load the service, so that the required classes are available.
$user->LoadService('ReportDefinitionService', ADWORDS_VERSION);
// Create selector.
$selector = new Selector();
$selector->fields = array('CampaignId');
//if ($timePeriod == "CUSTOM_DATE") {
//$selector->dateRange = new DateRange($dateFrom, $dateTo);
//}
// Create report definition.
$reportDefinition = new ReportDefinition();
$reportDefinition->selector = $selector;
$reportDefinition->reportName = 'Performance report #' . uniqid();
$reportDefinition->dateRangeType = 'LAST_7_DAYS';
//$reportDefinition->reportType = 'ACCOUNT_PERFORMANCE_REPORT';
$reportDefinition->reportType = 'CAMPAIGN_PERFORMANCE_REPORT';
$reportDefinition->downloadFormat = 'XML';
// Set additional options.
$options = array('version' => ADWORDS_VERSION);
$filePath = "reports/test.xml";
// Download report.
ReportUtils::DownloadReport($reportDefinition, $filePath, $user, $options);
printf("Report with name '%s' was downloaded to '%s'.\n", $reportDefinition->reportName, $filePath);}
function test(AdWordsUser $user) {
$service = $user->GetService('ConversionTrackerService', ADWORDS_VERSION);
$selector = new Selector();
$selector->fields = array(
'MostRecentConversionDate',
'LastReceivedRequestTime'
);
$data = $service->get($selector);
if (isset($data->entries)) {
print_r("<pre>");
print_r ($data->entries);
print_r("</pre>");
}else{
print "Empty";
}
}
function getAccountPerformanceReport(AdWordsUser $user) {
// Load the service.
$user->LoadService('ReportDefinitionService', ADWORDS_VERSION);
// Create selector.
$selector = new Selector();
$selector->fields = array(
'CampaignId',
'Impressions');
// Create report definition.
$reportDefinition = new ReportDefinition();
$reportDefinition->selector = $selector;
$reportDefinition->reportName = 'Criteria performance report #' . uniqid();
$reportDefinition->dateRangeType = 'LAST_7_DAYS';
//$reportDefinition->reportType = 'ACCOUNT_PERFORMANCE_REPORT';
$reportDefinition->reportType = 'CAMPAIGN_PERFORMANCE_REPORT';
$reportDefinition->downloadFormat = 'XML';
// Set additional options.
$options = array('version' => ADWORDS_VERSION);
$filePath = NULL;
print ReportUtils::DownloadReport($reportDefinition, $filePath, $user, $options);
//printf("Report with name '%s' was downloaded to '%s'.\n", $reportDefinition->reportName, $filePath);
}
$filePath = NULL;
print ReportUtils::DownloadReport($reportDefinition, $filePath, $user, $options);
$filePath = "reports/test.xml";
print ReportUtils::DownloadReport($reportDefinition, $filePath, $user, $options);
$filePath = "reports/test.xml";
ReportUtils::DownloadReport($reportDefinition, $filePath, $user, $options);
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<report>
<report-name name='Criteria performance report #5657055530886'/>
<date-range date='Nov 19, 2015-Nov 25, 2015'/>
<table>
<columns>
<column name='campaignID' display='Campaign ID'/>
</columns>
<row campaignID='xxxxx'/>
<row campaignID='xxxxx'/>
<row campaignID='xxxxx'/>
<row campaignID='xxxxx'/>
<row campaignID='xxxxx'/>
</table>
</report>
...
$report = ReportUtils::DownloadReport($reportDefinition, NULL, $user, $options);
$xml = simplexml_load_string($report);
print "<pre>";
print_r($xml);
print "</pre>";