Hi and thanks, it finally works!
Here the PHP code to Get the Keywords Stats for a selected client with
ReportDefinitionService and downloadReport as Array:
<?php
date_default_timezone_set( "Europe/Rome" );
error_reporting(E_STRICT | E_ALL);
require_once dirname(__FILE__) . '/../../src/Google/Api/Ads/AdWords/
Lib/AdWordsUser.php';
require_once dirname(__FILE__) . '/../../src/Google/Api/Ads/AdWords/
Util/ReportUtils.php';
$user = new AdWordsUser();
$user->SetClientId('123-123-1234'); // select the client with
clientId
$reportDefinitionService = $user-
>GetReportDefinitionService('v201008');
// Create selector.
$selector = new Selector();
$selector->fields = array('Id', 'AdGroupId', 'KeywordText',
'KeywordMatchType', 'Impressions', 'Clicks', 'Cost');
// Create report definition.
$reportDefinition = new ReportDefinition();
$reportDefinition->reportName = 'Keywords performance report #' .
time();
$reportDefinition->dateRangeType = 'YESTERDAY';
$reportDefinition->reportType = 'ACCOUNT_PERFORMANCE_REPORT';
$reportDefinition->downloadFormat = 'CSV';
$reportDefinition->selector = $selector;
// Create operations.
$operation = new ReportDefinitionOperation();
$operation->operand = $reportDefinition;
$operation->operator = 'ADD';
$operations = array($operation);
// Add report definition.
$result = $reportDefinitionService->mutate($operations);
// Display report definitions.
if ($result != null)
foreach ($result as $reportDefinition) {
$csv = ReportUtils::DownloadReport($reportDefinition->id, $path
= null, $user); // get the Report in $csv
// Get the result in Array
$rows = explode( "\n", $csv );
for($i=2;$i<count($rows)-1;$i++)
$array[]=explode( "," , $rows[$i] );
}
?>
Best,
Federico
www.federicoulfo.it
On Oct 30, 1:39 am, AdWords API Advisor <
adwordsapiadvi...@google.com>