Hi guys,
I had the following code, that I was using to create reports and they appeared in my client center. Now when the old API is deprecated I have problems doing the same thing. I need to be able to create keyword performance reports from a PHP script and they must appear in the client center. Any ideas how to do this with the new API?
P.S Until now I managed to create a ReportDefinition, but what is the way to use the created ReportDefinition object after that?
OLD CODE:
$reportDefinitionService = $user->GetReportDefinitionService('v201008');
$adGroupId = (float) $_GET['id'];
$adGroupName = $_GET['name'];
# Create ad group predicate.
$adGroupPredicate = new Predicate();
$adGroupPredicate->field = 'AdGroupId';
$adGroupPredicate->operator = 'EQUALS';
$adGroupPredicate->values = array($adGroupId);
# Create selector.
$selector = new Selector();
$selector->fields = array("AdGroupName", "KeywordText", "Impressions", "Ctr", "AveragePosition");
$selector->predicates = array($adGroupPredicate);
# Create report definition.
$reportDefinition = new ReportDefinition();
$reportDefinition->reportName = 'NEW Keywords performance report '.$adGroupName.' for adgroup #' . $adGroupId . ' @' . time();
$reportDefinition->reportType = 'KEYWORDS_PERFORMANCE_REPORT';
$reportDefinition->downloadFormat = 'CSVFOREXCEL';
$reportDefinition->dateRangeType = 'LAST_7_DAYS';
$reportDefinition->selector = $selector;
# Create operations.
$operation = new ReportDefinitionOperation();
$operation->operand = $reportDefinition;
$operation->operator = 'ADD';
# Add report definition and download.
$result = $reportDefinitionService->mutate(array($operation));