here's php code that will fetch reports for multiple clients, if you
have a lot of them (10 at a time):

<?php

error_reporting(E_STRICT | E_ALL);

// You can set the include path to src directory or reference
// AdWordsUser.php directly via require_once.
// $path = '/path/to/aw_api_php_lib/src';
include('../definedb.php'); //sets $adwordsAPIpath, which i keep
outside webroot on the server
include('./accountsArray.php'); //sets $adwordsAPIpath, uses $selector
= new ServicedAccountSelector(); to make an array of all accounts

$path = $adwordsAPIpath.'/../../live_api2/src/';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);

require_once 'Google/Api/Ads/AdWords/Lib/AdWordsUser.php';
require_once 'Google/Api/Ads/AdWords/Util/ReportUtils.php';

  // Get AdWordsUser from credentials in "../auth.ini"
  // relative to the AdWordsUser.php file's directory.
  $user = new AdWordsUser();
                $user->GetAuthToken(); //get the token now; this should force 
php
not to fetch the token for each fork()

  // Log SOAP XML request and response.
  $user->LogDefaults();

  // Load ReportDefinitionService so that the required classes are
available.
  $user->LoadService('ReportDefinitionService', 'v201109');

  // Create selector.
  $selector = new Selector();
$selector->fields = array('ExternalCustomerId',
'AccountDescriptiveName', 'PrimaryUserLogin', 'Date', 'Id', 'Name',
'Impressions', 'Clicks', 'Cost');
  //$selector->predicates[] =
      //new Predicate('Status', 'IN', array('ENABLED', 'PAUSED'));

  // Create report definition.
  $reportDefinition = new ReportDefinition();
  $reportDefinition->selector = $selector;
  $reportDefinition->reportName = 'Campaign performance report #' .
time();
  $reportDefinition->dateRangeType = 'LAST_7_DAYS';
  $reportDefinition->reportType = 'CAMPAIGN_PERFORMANCE_REPORT';
  $reportDefinition->downloadFormat = 'CSV';
  $reportDefinition->includeZeroImpressions = FALSE;

  $options = array('version' => 'v201109', 'returnMoneyInMicros' =>
FALSE);

$pids = array();

$j = 0;

for ($i=0; $i<count($accountsArray); $i++) {

        if($j==10) { echo $j." ---\n"; $j=0; }

        $pids[$i] = pcntl_fork();

  if(!$pids[$i]) {

    // child process

        try {
  // Get AdWordsUser from credentials in "../auth.ini"
  // relative to the AdWordsUser.php file's directory.

        $customerId = $accountsArray[$i];

        $user->SetClientId($customerId);

        $fileName = "7days-".$customerId.".csv";
        $path = dirname(__FILE__) . '/../reports/7days/' . $fileName;

  ReportUtils::DownloadReport($reportDefinition, $path, $user,
$options);

  printf("Report with name '%s' was downloaded to '%s'.\n",
      $reportDefinition->reportName, $fileName);

  } catch (Exception $e) {
  print $e->getMessage();
}

    exit();
  }

        $j++;

        }


On Nov 17, 6:20 pm, Eric Koleda <eric.kol...@google.com> wrote:
> Hi,
>
> Creating and using existing report definitions will be supported at least
> until the sunset of v201101, which is scheduled for late February 2012.  By
> that time you will need to have moved your reporting to ad-hoc reports.
>
> Best,
> - Eric Koleda, AdWords API Team

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en

Reply via email to