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 <[email protected]>
wrote:
> Hi Frederico,
>
> There is no field called "clientCustomerId" that is available for the
> report type ACCOUNT_PERFORMANCE_REPORT:
>
> http://code.google.com/apis/adwords/docs/appendix/reports.html#account
>
> v201008 reports cannot target multiple client account, so ensure that
> the report definition is created in the account you wish to report on
> (set the clientCustomerId header in the request).
>
> Best,
> - Eric Koleda, AdWords API Tea,
>
> On Oct 27, 4:48 pm, federico ulfo <[email protected]> wrote:
>
> > Hi Anash,
> > I tried to modify AddKeywordsPerformanceReportDefinition.php,
> > I receive INVALID_FIELD_NAME_FOR_REPORT error,
> > what's the correct Predicate::field for get the Customer stats?
> > ---
> > $user = new AdWordsUser();
> > $user->LogDefaults();
>
> > // Get the GetReportDefinitionService.
> > $reportDefinitionService = $user-
>
> > >GetReportDefinitionService('v201008');
>
> > // Create ad group predicate.
> > $customer = new Predicate();
> > $customer->field = 'clientCustomerId';
> > $customer->operator = 'EQUALS';
> > $customer->values = array("209-212-1229");
>
> > // Create selector.
> > $selector = new Selector();
> > $selector->fields = array( 'Impressions', 'Clicks' );
> > $selector->predicates = array($customer);
>
> > // Create report definition.
> > $reportDefinition = new ReportDefinition();
> > $reportDefinition->reportName = 'Account Stats#' . time();
> > $reportDefinition->dateRangeType = 'YESTERDAY';
> > $reportDefinition->reportType = 'ACCOUNT_PERFORMANCE_REPORT';
> > $reportDefinition->downloadFormat = 'XML';
> > $reportDefinition->selector = $selector;
>
> > // Create operations.
> > $operation = new ReportDefinitionOperation();
> > $operation->operand = $reportDefinition;
> > $operation->operator = 'ADD';
>
> > $operations = array($operation);
>
> > // Add report definition.
> > $result = $reportDefinitionService->mutate($operations);
> > ---
>
> > Thanks,
> > Federico
>
> > On Oct 27, 6:01 am, AdWords API Advisor <[email protected]>
> > wrote:
>
> > > Hi Federico,
>
> > > Try Account Performance report which was newly added in v201008.
> > > Seehttp://code.google.com/apis/adwords/docs/appendix/reports.html#account
> > > for more details.
>
> > > Cheers,
> > > Anash P. Oommen,
> > > AdWords API Advisor.
>
> > > On Oct 26, 5:15 pm, federico ulfo <[email protected]> wrote:
>
> > > > Hey Anash,
>
> > > > I mean the stats of a selected client (client_id: xxx-xxx-xxxx)
> > > > so clicks, impression, avg cpc, avg cpm, ctr, avg position ...
>
> > > > thanks
> > > > Federicowww.federicoulfo.it
>
> > > > On Oct 26, 12:12 pm, AdWords API Advisor
>
> > > > <[email protected]> wrote:
> > > > > Hi Federico,
>
> > > > > Can you please clarify your question? What do you mean by "tot. report
> > > > > of the selected client"?
>
> > > > > Cheers,
> > > > > Anash P. Oommen,
> > > > > AdWords API Advisor.
>
> > > > > On Oct 25, 10:32 pm, Federico Ulfo <[email protected]> wrote:
>
> > > > > > Hi Anash,
>
> > > > > > thanks, 1st solution works well for me!
> > > > > > How can I get the tot. report of the selected client? It looks like
> > > > > > is
> > > > > > not always the sum of all campaign reports.
>
> > > > > > Do you think is it possible to do a single report using
> > > > > > scheduleRerportJob?http://code.google.com/apis/adwords/docs/developer/ReportService.html...
>
> > > > > > When completed I'll share my PHP code.
>
> > > > > > Best,
> > > > > > Federicowww.federicoulfo.it
>
> > > > > > On Oct 25, 1:26 pm, AdWords API Advisor
> > > > > > <[email protected]>
> > > > > > wrote:
>
> > > > > > > HI Federico,
>
> > > > > > > You can't get the whole account details in a single call, you will
> > > > > > > need at least 4 API calls (a CampaignService.get(),
> > > > > > > AdGroupService.get(), AdGroupAdService.get() and
> > > > > > > AdGroupCriterionService.get()), and a reasonable amount of code to
> > > > > > > organize the objects in the required hierarchical order.
>
> > > > > > > Another alternative is to run 1 performancereporteach for
> > > > > > > Campaign,
> > > > > > > AdGroups, Keywords and Ads, but still you need code to parse and
> > > > > > > put
> > > > > > > the stats in the desired hierarchical form.
>
> > > > > > > Cheers,
> > > > > > > Anash P. Oommen,
> > > > > > > AdWords API Advisor.
>
> > > > > > > On Oct 23, 7:02 pm, federico ulfo <[email protected]> wrote:
>
> > > > > > > > Hi,
> > > > > > > > is it possible to get the complete clientreport(as follow) in a
> > > > > > > > single API call?
> > > > > > > > CLIENT clicks, impression, avg CPC, avg
> > > > > > > > CPM...
> > > > > > > > -- CAMPAIGNS
> > > > > > > > -- GROUPS
> > > > > > > > -- KEYWORDS
>
> > > > > > > > Thanks,
> > > > > > > > Federico
>
>
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en